mirror of
https://github.com/ReneLergner/WPinternals.git
synced 2026-06-20 22:21:13 +10:00
fix: Modern Flash App Label mode switching
This commit is contained in:
@@ -26,8 +26,6 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
internal class LumiaBootManagerAppModel : NokiaFlashModel
|
internal class LumiaBootManagerAppModel : NokiaFlashModel
|
||||||
{
|
{
|
||||||
private readonly PhoneInfo Info = new();
|
|
||||||
|
|
||||||
internal enum SecureBootKeyType : byte
|
internal enum SecureBootKeyType : byte
|
||||||
{
|
{
|
||||||
Retail = 0,
|
Retail = 0,
|
||||||
@@ -110,108 +108,10 @@ namespace WPinternals
|
|||||||
// NOKV = Info Query
|
// NOKV = Info Query
|
||||||
|
|
||||||
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
||||||
|
ReadPhoneInfoCommon();
|
||||||
|
|
||||||
PhoneInfo Result = Info;
|
PhoneInfo Result = Info;
|
||||||
|
|
||||||
if (Result.State == PhoneInfoState.Empty)
|
|
||||||
{
|
|
||||||
byte[] Request = new byte[4];
|
|
||||||
ByteOperations.WriteAsciiString(Request, 0, InfoQuerySignature);
|
|
||||||
byte[] Response = ExecuteRawMethod(Request);
|
|
||||||
if ((Response != null) && (ByteOperations.ReadAsciiString(Response, 0, 4) != "NOKU"))
|
|
||||||
{
|
|
||||||
Result.App = (FlashAppType)Response[5];
|
|
||||||
|
|
||||||
switch (Result.App)
|
|
||||||
{
|
|
||||||
case FlashAppType.BootManager:
|
|
||||||
Result.BootManagerProtocolVersionMajor = Response[6];
|
|
||||||
Result.BootManagerProtocolVersionMinor = Response[7];
|
|
||||||
Result.BootManagerVersionMajor = Response[8];
|
|
||||||
Result.BootManagerVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.FlashApp:
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.FlashAppVersionMajor = Response[8];
|
|
||||||
Result.FlashAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.PhoneInfoApp:
|
|
||||||
Result.PhoneInfoAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.PhoneInfoAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.PhoneInfoAppVersionMajor = Response[8];
|
|
||||||
Result.PhoneInfoAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte SubblockCount = Response[10];
|
|
||||||
int SubblockOffset = 11;
|
|
||||||
|
|
||||||
for (int i = 0; i < SubblockCount; i++)
|
|
||||||
{
|
|
||||||
byte SubblockID = Response[SubblockOffset + 0x00];
|
|
||||||
UInt16 SubblockLength = BigEndian.ToUInt16(Response, SubblockOffset + 0x01);
|
|
||||||
int SubblockPayloadOffset = SubblockOffset + 3;
|
|
||||||
byte SubblockVersion;
|
|
||||||
switch (SubblockID)
|
|
||||||
{
|
|
||||||
case 0x01:
|
|
||||||
Result.TransferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x02:
|
|
||||||
Result.WriteBufferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x03:
|
|
||||||
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x04:
|
|
||||||
if (Result.App == FlashAppType.BootManager)
|
|
||||||
{
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[SubblockPayloadOffset + 0x00];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[SubblockPayloadOffset + 0x01];
|
|
||||||
Result.FlashAppVersionMajor = Response[SubblockPayloadOffset + 0x02];
|
|
||||||
Result.FlashAppVersionMinor = Response[SubblockPayloadOffset + 0x03];
|
|
||||||
}
|
|
||||||
else if (Result.App == FlashAppType.FlashApp)
|
|
||||||
{
|
|
||||||
Result.SdCardSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x05:
|
|
||||||
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
|
||||||
break;
|
|
||||||
case 0x0D:
|
|
||||||
Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1;
|
|
||||||
break;
|
|
||||||
case 0x0F:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x03
|
|
||||||
Result.PlatformSecureBootEnabled = Response[SubblockPayloadOffset + 0x01] == 0x01;
|
|
||||||
Result.SecureFfuEnabled = Response[SubblockPayloadOffset + 0x02] == 0x01;
|
|
||||||
Result.JtagDisabled = Response[SubblockPayloadOffset + 0x03] == 0x01;
|
|
||||||
Result.RdcPresent = Response[SubblockPayloadOffset + 0x04] == 0x01;
|
|
||||||
Result.Authenticated = (Response[SubblockPayloadOffset + 0x05] == 0x01) || (Response[SubblockPayloadOffset + 0x05] == 0x02);
|
|
||||||
Result.UefiSecureBootEnabled = Response[SubblockPayloadOffset + 0x06] == 0x01;
|
|
||||||
Result.SecondaryHardwareKeyPresent = Response[SubblockPayloadOffset + 0x07] == 0x01;
|
|
||||||
break;
|
|
||||||
case 0x10:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x01
|
|
||||||
Result.SecureFfuSupportedProtocolMask = BigEndian.ToUInt16(Response, SubblockPayloadOffset + 0x01);
|
|
||||||
break;
|
|
||||||
case 0x1F:
|
|
||||||
Result.MmosOverUsbSupported = Response[SubblockPayloadOffset] == 1;
|
|
||||||
break;
|
|
||||||
case 0x20:
|
|
||||||
// CRC header info
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SubblockOffset += SubblockLength + 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.State = PhoneInfoState.Basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.IsBootloaderSecure = !(Info.Authenticated || Info.RdcPresent || !Info.SecureFfuEnabled);
|
|
||||||
|
|
||||||
if (!PhoneInfoLogged)
|
if (!PhoneInfoLogged)
|
||||||
{
|
{
|
||||||
Result.Log(LogType.FileOnly);
|
Result.Log(LogType.FileOnly);
|
||||||
|
|||||||
@@ -170,7 +170,7 @@ namespace WPinternals
|
|||||||
ProductType = ProductType.ToUpper();
|
ProductType = ProductType.ToUpper();
|
||||||
if (ProductType.StartsWith("RM") && !ProductType.StartsWith("RM-"))
|
if (ProductType.StartsWith("RM") && !ProductType.StartsWith("RM-"))
|
||||||
{
|
{
|
||||||
ProductType = "RM-" + ProductType[2..];
|
ProductType = $"RM-{ProductType[2..]}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -212,10 +212,10 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
|
|
||||||
SoftwarePackage Package = null;
|
SoftwarePackage Package = null;
|
||||||
using (MemoryStream JsonStream2 = new(Encoding.UTF8.GetBytes(JsonResultString)))
|
using (MemoryStream JsonResultStream = new(Encoding.UTF8.GetBytes(JsonResultString)))
|
||||||
{
|
{
|
||||||
DataContractJsonSerializer Serializer2 = new(typeof(SoftwarePackages));
|
DataContractJsonSerializer SoftwarePackagesJsonSerializer = new(typeof(SoftwarePackages));
|
||||||
SoftwarePackages SoftwarePackages = (SoftwarePackages)Serializer2.ReadObject(JsonStream2);
|
SoftwarePackages SoftwarePackages = (SoftwarePackages)SoftwarePackagesJsonSerializer.ReadObject(JsonResultStream);
|
||||||
if (SoftwarePackages != null)
|
if (SoftwarePackages != null)
|
||||||
{
|
{
|
||||||
foreach (SoftwarePackage pkg in SoftwarePackages.softwarePackages)
|
foreach (SoftwarePackage pkg in SoftwarePackages.softwarePackages)
|
||||||
|
|||||||
@@ -70,7 +70,6 @@ namespace WPinternals
|
|||||||
|
|
||||||
internal class LumiaFlashAppModel : NokiaFlashModel
|
internal class LumiaFlashAppModel : NokiaFlashModel
|
||||||
{
|
{
|
||||||
private readonly PhoneInfo Info = new();
|
|
||||||
private UefiSecurityStatusResponse _SecurityStatus = null;
|
private UefiSecurityStatusResponse _SecurityStatus = null;
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -163,106 +162,10 @@ namespace WPinternals
|
|||||||
// NOKV = Info Query
|
// NOKV = Info Query
|
||||||
|
|
||||||
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
||||||
|
ReadPhoneInfoCommon();
|
||||||
|
|
||||||
PhoneInfo Result = Info;
|
PhoneInfo Result = Info;
|
||||||
|
|
||||||
if (Result.State == PhoneInfoState.Empty)
|
|
||||||
{
|
|
||||||
byte[] Request = new byte[4];
|
|
||||||
ByteOperations.WriteAsciiString(Request, 0, InfoQuerySignature);
|
|
||||||
byte[] Response = ExecuteRawMethod(Request);
|
|
||||||
if ((Response != null) && (ByteOperations.ReadAsciiString(Response, 0, 4) != "NOKU"))
|
|
||||||
{
|
|
||||||
Result.App = (FlashAppType)Response[5];
|
|
||||||
|
|
||||||
switch (Result.App)
|
|
||||||
{
|
|
||||||
case FlashAppType.BootManager:
|
|
||||||
Result.BootManagerProtocolVersionMajor = Response[6];
|
|
||||||
Result.BootManagerProtocolVersionMinor = Response[7];
|
|
||||||
Result.BootManagerVersionMajor = Response[8];
|
|
||||||
Result.BootManagerVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.FlashApp:
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.FlashAppVersionMajor = Response[8];
|
|
||||||
Result.FlashAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.PhoneInfoApp:
|
|
||||||
Result.PhoneInfoAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.PhoneInfoAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.PhoneInfoAppVersionMajor = Response[8];
|
|
||||||
Result.PhoneInfoAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte SubblockCount = Response[10];
|
|
||||||
int SubblockOffset = 11;
|
|
||||||
|
|
||||||
for (int i = 0; i < SubblockCount; i++)
|
|
||||||
{
|
|
||||||
byte SubblockID = Response[SubblockOffset + 0x00];
|
|
||||||
UInt16 SubblockLength = BigEndian.ToUInt16(Response, SubblockOffset + 0x01);
|
|
||||||
int SubblockPayloadOffset = SubblockOffset + 3;
|
|
||||||
byte SubblockVersion;
|
|
||||||
switch (SubblockID)
|
|
||||||
{
|
|
||||||
case 0x01:
|
|
||||||
Result.TransferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x02:
|
|
||||||
Result.WriteBufferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x03:
|
|
||||||
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x04:
|
|
||||||
if (Result.App == FlashAppType.BootManager)
|
|
||||||
{
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[SubblockPayloadOffset + 0x00];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[SubblockPayloadOffset + 0x01];
|
|
||||||
Result.FlashAppVersionMajor = Response[SubblockPayloadOffset + 0x02];
|
|
||||||
Result.FlashAppVersionMinor = Response[SubblockPayloadOffset + 0x03];
|
|
||||||
}
|
|
||||||
else if (Result.App == FlashAppType.FlashApp)
|
|
||||||
{
|
|
||||||
Result.SdCardSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x05:
|
|
||||||
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
|
||||||
break;
|
|
||||||
case 0x0D:
|
|
||||||
Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1;
|
|
||||||
break;
|
|
||||||
case 0x0F:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x03
|
|
||||||
Result.PlatformSecureBootEnabled = Response[SubblockPayloadOffset + 0x01] == 0x01;
|
|
||||||
Result.SecureFfuEnabled = Response[SubblockPayloadOffset + 0x02] == 0x01;
|
|
||||||
Result.JtagDisabled = Response[SubblockPayloadOffset + 0x03] == 0x01;
|
|
||||||
Result.RdcPresent = Response[SubblockPayloadOffset + 0x04] == 0x01;
|
|
||||||
Result.Authenticated = (Response[SubblockPayloadOffset + 0x05] == 0x01) || (Response[SubblockPayloadOffset + 0x05] == 0x02);
|
|
||||||
Result.UefiSecureBootEnabled = Response[SubblockPayloadOffset + 0x06] == 0x01;
|
|
||||||
Result.SecondaryHardwareKeyPresent = Response[SubblockPayloadOffset + 0x07] == 0x01;
|
|
||||||
break;
|
|
||||||
case 0x10:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x01
|
|
||||||
Result.SecureFfuSupportedProtocolMask = BigEndian.ToUInt16(Response, SubblockPayloadOffset + 0x01);
|
|
||||||
break;
|
|
||||||
case 0x1F:
|
|
||||||
Result.MmosOverUsbSupported = Response[SubblockPayloadOffset] == 1;
|
|
||||||
break;
|
|
||||||
case 0x20:
|
|
||||||
// CRC header info
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SubblockOffset += SubblockLength + 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.State = PhoneInfoState.Basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ExtendedInfo && (Result.State == PhoneInfoState.Basic))
|
if (ExtendedInfo && (Result.State == PhoneInfoState.Basic))
|
||||||
{
|
{
|
||||||
if (Result.App == FlashAppType.FlashApp)
|
if (Result.App == FlashAppType.FlashApp)
|
||||||
@@ -274,8 +177,6 @@ namespace WPinternals
|
|||||||
Result.State = PhoneInfoState.Extended;
|
Result.State = PhoneInfoState.Extended;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result.IsBootloaderSecure = !(Info.Authenticated || Info.RdcPresent || !Info.SecureFfuEnabled);
|
|
||||||
|
|
||||||
if (!PhoneInfoLogged)
|
if (!PhoneInfoLogged)
|
||||||
{
|
{
|
||||||
Result.Log(LogType.FileOnly);
|
Result.Log(LogType.FileOnly);
|
||||||
|
|||||||
@@ -26,8 +26,6 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
internal class LumiaPhoneInfoAppModel : NokiaFlashModel
|
internal class LumiaPhoneInfoAppModel : NokiaFlashModel
|
||||||
{
|
{
|
||||||
private readonly PhoneInfo Info = new();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Not valid commands
|
// Not valid commands
|
||||||
//
|
//
|
||||||
@@ -101,106 +99,10 @@ namespace WPinternals
|
|||||||
// NOKV = Info Query
|
// NOKV = Info Query
|
||||||
|
|
||||||
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
||||||
|
ReadPhoneInfoCommon();
|
||||||
|
|
||||||
PhoneInfo Result = Info;
|
PhoneInfo Result = Info;
|
||||||
|
|
||||||
if (Result.State == PhoneInfoState.Empty)
|
|
||||||
{
|
|
||||||
byte[] Request = new byte[4];
|
|
||||||
ByteOperations.WriteAsciiString(Request, 0, InfoQuerySignature);
|
|
||||||
byte[] Response = ExecuteRawMethod(Request);
|
|
||||||
if ((Response != null) && (ByteOperations.ReadAsciiString(Response, 0, 4) != "NOKU"))
|
|
||||||
{
|
|
||||||
Result.App = (FlashAppType)Response[5];
|
|
||||||
|
|
||||||
switch (Result.App)
|
|
||||||
{
|
|
||||||
case FlashAppType.BootManager:
|
|
||||||
Result.BootManagerProtocolVersionMajor = Response[6];
|
|
||||||
Result.BootManagerProtocolVersionMinor = Response[7];
|
|
||||||
Result.BootManagerVersionMajor = Response[8];
|
|
||||||
Result.BootManagerVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.FlashApp:
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.FlashAppVersionMajor = Response[8];
|
|
||||||
Result.FlashAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
case FlashAppType.PhoneInfoApp:
|
|
||||||
Result.PhoneInfoAppProtocolVersionMajor = Response[6];
|
|
||||||
Result.PhoneInfoAppProtocolVersionMinor = Response[7];
|
|
||||||
Result.PhoneInfoAppVersionMajor = Response[8];
|
|
||||||
Result.PhoneInfoAppVersionMinor = Response[9];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
byte SubblockCount = Response[10];
|
|
||||||
int SubblockOffset = 11;
|
|
||||||
|
|
||||||
for (int i = 0; i < SubblockCount; i++)
|
|
||||||
{
|
|
||||||
byte SubblockID = Response[SubblockOffset + 0x00];
|
|
||||||
UInt16 SubblockLength = BigEndian.ToUInt16(Response, SubblockOffset + 0x01);
|
|
||||||
int SubblockPayloadOffset = SubblockOffset + 3;
|
|
||||||
byte SubblockVersion;
|
|
||||||
switch (SubblockID)
|
|
||||||
{
|
|
||||||
case 0x01:
|
|
||||||
Result.TransferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x02:
|
|
||||||
Result.WriteBufferSize = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x03:
|
|
||||||
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
break;
|
|
||||||
case 0x04:
|
|
||||||
if (Result.App == FlashAppType.BootManager)
|
|
||||||
{
|
|
||||||
Result.FlashAppProtocolVersionMajor = Response[SubblockPayloadOffset + 0x00];
|
|
||||||
Result.FlashAppProtocolVersionMinor = Response[SubblockPayloadOffset + 0x01];
|
|
||||||
Result.FlashAppVersionMajor = Response[SubblockPayloadOffset + 0x02];
|
|
||||||
Result.FlashAppVersionMinor = Response[SubblockPayloadOffset + 0x03];
|
|
||||||
}
|
|
||||||
else if (Result.App == FlashAppType.FlashApp)
|
|
||||||
{
|
|
||||||
Result.SdCardSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 0x05:
|
|
||||||
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
|
||||||
break;
|
|
||||||
case 0x0D:
|
|
||||||
Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1;
|
|
||||||
break;
|
|
||||||
case 0x0F:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x03
|
|
||||||
Result.PlatformSecureBootEnabled = Response[SubblockPayloadOffset + 0x01] == 0x01;
|
|
||||||
Result.SecureFfuEnabled = Response[SubblockPayloadOffset + 0x02] == 0x01;
|
|
||||||
Result.JtagDisabled = Response[SubblockPayloadOffset + 0x03] == 0x01;
|
|
||||||
Result.RdcPresent = Response[SubblockPayloadOffset + 0x04] == 0x01;
|
|
||||||
Result.Authenticated = (Response[SubblockPayloadOffset + 0x05] == 0x01) || (Response[SubblockPayloadOffset + 0x05] == 0x02);
|
|
||||||
Result.UefiSecureBootEnabled = Response[SubblockPayloadOffset + 0x06] == 0x01;
|
|
||||||
Result.SecondaryHardwareKeyPresent = Response[SubblockPayloadOffset + 0x07] == 0x01;
|
|
||||||
break;
|
|
||||||
case 0x10:
|
|
||||||
SubblockVersion = Response[SubblockPayloadOffset]; // 0x01
|
|
||||||
Result.SecureFfuSupportedProtocolMask = BigEndian.ToUInt16(Response, SubblockPayloadOffset + 0x01);
|
|
||||||
break;
|
|
||||||
case 0x1F:
|
|
||||||
Result.MmosOverUsbSupported = Response[SubblockPayloadOffset] == 1;
|
|
||||||
break;
|
|
||||||
case 0x20:
|
|
||||||
// CRC header info
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
SubblockOffset += SubblockLength + 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Result.State = PhoneInfoState.Basic;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ExtendedInfo && (Result.State == PhoneInfoState.Basic))
|
if (ExtendedInfo && (Result.State == PhoneInfoState.Basic))
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -217,8 +119,6 @@ namespace WPinternals
|
|||||||
Result.State = PhoneInfoState.Extended;
|
Result.State = PhoneInfoState.Extended;
|
||||||
}
|
}
|
||||||
|
|
||||||
Result.IsBootloaderSecure = !(Info.Authenticated || Info.RdcPresent || !Info.SecureFfuEnabled);
|
|
||||||
|
|
||||||
if (!PhoneInfoLogged)
|
if (!PhoneInfoLogged)
|
||||||
{
|
{
|
||||||
Result.Log(LogType.FileOnly);
|
Result.Log(LogType.FileOnly);
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
namespace WPinternals
|
namespace WPinternals
|
||||||
{
|
{
|
||||||
@@ -30,7 +31,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
private string _devicePath;
|
private string _devicePath;
|
||||||
|
|
||||||
private readonly PhoneInfo Info = new();
|
internal readonly PhoneInfo Info = new();
|
||||||
|
|
||||||
internal event InterfaceChangedHandler InterfaceChanged = delegate { };
|
internal event InterfaceChangedHandler InterfaceChanged = delegate { };
|
||||||
|
|
||||||
@@ -60,7 +61,20 @@ namespace WPinternals
|
|||||||
internal void SwitchToBootManagerContext(bool DisableTimeOut = true)
|
internal void SwitchToBootManagerContext(bool DisableTimeOut = true)
|
||||||
{
|
{
|
||||||
PhoneInfo info = ReadPhoneInfoCommon();
|
PhoneInfo info = ReadPhoneInfoCommon();
|
||||||
bool ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
|
||||||
|
bool ModernFlashApp = false;
|
||||||
|
switch (info.App)
|
||||||
|
{
|
||||||
|
case FlashAppType.FlashApp:
|
||||||
|
ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.PhoneInfoApp:
|
||||||
|
ModernFlashApp = info.PhoneInfoAppVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.BootManager:
|
||||||
|
ModernFlashApp = info.BootManagerVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] Request = new byte[7];
|
byte[] Request = new byte[7];
|
||||||
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "B");
|
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "B");
|
||||||
@@ -95,7 +109,20 @@ namespace WPinternals
|
|||||||
internal void SwitchToPhoneInfoAppContext()
|
internal void SwitchToPhoneInfoAppContext()
|
||||||
{
|
{
|
||||||
PhoneInfo info = ReadPhoneInfoCommon();
|
PhoneInfo info = ReadPhoneInfoCommon();
|
||||||
bool ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
|
||||||
|
bool ModernFlashApp = false;
|
||||||
|
switch (info.App)
|
||||||
|
{
|
||||||
|
case FlashAppType.FlashApp:
|
||||||
|
ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.PhoneInfoApp:
|
||||||
|
ModernFlashApp = info.PhoneInfoAppVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.BootManager:
|
||||||
|
ModernFlashApp = info.BootManagerVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] Request = new byte[7];
|
byte[] Request = new byte[7];
|
||||||
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "P");
|
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "P");
|
||||||
@@ -141,7 +168,20 @@ namespace WPinternals
|
|||||||
internal void SwitchToFlashAppContext()
|
internal void SwitchToFlashAppContext()
|
||||||
{
|
{
|
||||||
PhoneInfo info = ReadPhoneInfoCommon();
|
PhoneInfo info = ReadPhoneInfoCommon();
|
||||||
bool ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
|
||||||
|
bool ModernFlashApp = false;
|
||||||
|
switch (info.App)
|
||||||
|
{
|
||||||
|
case FlashAppType.FlashApp:
|
||||||
|
ModernFlashApp = info.FlashAppProtocolVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.PhoneInfoApp:
|
||||||
|
ModernFlashApp = info.PhoneInfoAppVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
case FlashAppType.BootManager:
|
||||||
|
ModernFlashApp = info.BootManagerVersionMajor >= 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
byte[] Request = new byte[7];
|
byte[] Request = new byte[7];
|
||||||
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "F"); // This will stop charging the phone
|
ByteOperations.WriteAsciiString(Request, 0, SwitchModeSignature + "F"); // This will stop charging the phone
|
||||||
@@ -203,7 +243,6 @@ namespace WPinternals
|
|||||||
// NOKH = Get Phone Info (IMEI and info from Product.dat) - Not available on some phones, like Lumia 640.
|
// NOKH = Get Phone Info (IMEI and info from Product.dat) - Not available on some phones, like Lumia 640.
|
||||||
// NOKV = Info Query
|
// NOKV = Info Query
|
||||||
|
|
||||||
bool PhoneInfoLogged = Info.State != PhoneInfoState.Empty;
|
|
||||||
PhoneInfo Result = Info;
|
PhoneInfo Result = Info;
|
||||||
|
|
||||||
if (Result.State == PhoneInfoState.Empty)
|
if (Result.State == PhoneInfoState.Empty)
|
||||||
@@ -257,6 +296,19 @@ namespace WPinternals
|
|||||||
case 0x03:
|
case 0x03:
|
||||||
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
||||||
break;
|
break;
|
||||||
|
case 0x04:
|
||||||
|
if (Result.App == FlashAppType.BootManager)
|
||||||
|
{
|
||||||
|
Result.FlashAppProtocolVersionMajor = Response[SubblockPayloadOffset + 0x00];
|
||||||
|
Result.FlashAppProtocolVersionMinor = Response[SubblockPayloadOffset + 0x01];
|
||||||
|
Result.FlashAppVersionMajor = Response[SubblockPayloadOffset + 0x02];
|
||||||
|
Result.FlashAppVersionMinor = Response[SubblockPayloadOffset + 0x03];
|
||||||
|
}
|
||||||
|
else if (Result.App == FlashAppType.FlashApp)
|
||||||
|
{
|
||||||
|
Result.SdCardSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
||||||
break;
|
break;
|
||||||
@@ -293,11 +345,6 @@ namespace WPinternals
|
|||||||
|
|
||||||
Result.IsBootloaderSecure = !(Info.Authenticated || Info.RdcPresent || !Info.SecureFfuEnabled);
|
Result.IsBootloaderSecure = !(Info.Authenticated || Info.RdcPresent || !Info.SecureFfuEnabled);
|
||||||
|
|
||||||
if (!PhoneInfoLogged)
|
|
||||||
{
|
|
||||||
Result.Log(LogType.FileOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -426,8 +426,8 @@ namespace WPinternals
|
|||||||
private void InterfaceChanged(PhoneInterfaces NewInterface, string DevicePath)
|
private void InterfaceChanged(PhoneInterfaces NewInterface, string DevicePath)
|
||||||
{
|
{
|
||||||
LastInterface = CurrentInterface;
|
LastInterface = CurrentInterface;
|
||||||
CurrentInterface = null;
|
|
||||||
|
|
||||||
|
CurrentInterface = null;
|
||||||
if (CurrentModel != null)
|
if (CurrentModel != null)
|
||||||
{
|
{
|
||||||
CurrentModel.Dispose();
|
CurrentModel.Dispose();
|
||||||
|
|||||||
@@ -387,7 +387,7 @@ namespace WPinternals
|
|||||||
break;
|
break;
|
||||||
case PhoneInterfaces.Lumia_Bootloader:
|
case PhoneInterfaces.Lumia_Bootloader:
|
||||||
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
||||||
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().FlashAppProtocolVersionMajor >= 2;
|
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().PhoneInfoAppVersionMajor >= 2;
|
||||||
if (ModernFlashApp)
|
if (ModernFlashApp)
|
||||||
{
|
{
|
||||||
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToBootManagerContext();
|
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToBootManagerContext();
|
||||||
@@ -397,7 +397,7 @@ namespace WPinternals
|
|||||||
break;
|
break;
|
||||||
case PhoneInterfaces.Lumia_PhoneInfo: // attempt to boot from limited phone info to full phone info
|
case PhoneInterfaces.Lumia_PhoneInfo: // attempt to boot from limited phone info to full phone info
|
||||||
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
||||||
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().FlashAppProtocolVersionMajor >= 2;
|
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().PhoneInfoAppVersionMajor >= 2;
|
||||||
if (ModernFlashApp)
|
if (ModernFlashApp)
|
||||||
{
|
{
|
||||||
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToPhoneInfoAppContext();
|
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToPhoneInfoAppContext();
|
||||||
@@ -410,7 +410,7 @@ namespace WPinternals
|
|||||||
break;
|
break;
|
||||||
case PhoneInterfaces.Lumia_Flash:
|
case PhoneInterfaces.Lumia_Flash:
|
||||||
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
||||||
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().FlashAppProtocolVersionMajor >= 2;
|
ModernFlashApp = ((LumiaPhoneInfoAppModel)CurrentModel).ReadPhoneInfo().PhoneInfoAppVersionMajor >= 2;
|
||||||
if (ModernFlashApp)
|
if (ModernFlashApp)
|
||||||
{
|
{
|
||||||
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToFlashAppContext();
|
((LumiaPhoneInfoAppModel)CurrentModel).SwitchToFlashAppContext();
|
||||||
@@ -713,14 +713,32 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SwitchFromPhoneInfoToLabelMode(bool Continuation = false)
|
private void SwitchFromPhoneInfoToLabelMode(bool Continuation = false)
|
||||||
{
|
{
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||||
|
{
|
||||||
|
throw new WPinternalsException("Unexpected Mode");
|
||||||
|
}
|
||||||
|
|
||||||
string ProgressText = Continuation ? "And now preparing to boot the phone to Label mode..." : "Preparing to boot the phone to Label mode...";
|
string ProgressText = Continuation ? "And now preparing to boot the phone to Label mode..." : "Preparing to boot the phone to Label mode...";
|
||||||
|
|
||||||
((LumiaBootManagerAppModel)CurrentModel).SwitchToFlashAppContext();
|
PhoneInfo PhoneInfoAppInfo = ((LumiaPhoneInfoAppModel)PhoneNotifier.CurrentModel).ReadPhoneInfo(ExtendedInfo: true);
|
||||||
await PhoneNotifier.WaitForArrival();
|
|
||||||
|
|
||||||
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)CurrentModel;
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
((LumiaPhoneInfoAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext();
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||||
|
{
|
||||||
|
await PhoneNotifier.WaitForArrival();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||||
|
{
|
||||||
|
throw new WPinternalsException("Unexpected Mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
|
||||||
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: true);
|
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: true);
|
||||||
|
|
||||||
if (Info.MmosOverUsbSupported)
|
if (Info.MmosOverUsbSupported)
|
||||||
@@ -732,13 +750,18 @@ namespace WPinternals
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ModeSwitchProgressWrapper(ProgressText, null);
|
ModeSwitchProgressWrapper(ProgressText, null);
|
||||||
|
|
||||||
string TempFolder = Environment.GetEnvironmentVariable("TEMP") + @"\WPInternals";
|
string TempFolder = Environment.GetEnvironmentVariable("TEMP") + @"\WPInternals";
|
||||||
if (Info.Type == "RM-1152")
|
|
||||||
|
if (PhoneInfoAppInfo.Type == "RM-1152")
|
||||||
{
|
{
|
||||||
Info.Type = "RM-1151";
|
PhoneInfoAppInfo.Type = "RM-1151";
|
||||||
}
|
}
|
||||||
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(Info.Type, Info.Firmware);
|
|
||||||
SetWorkingStatus("Downloading " + Info.Type + " Test Mode package...", MaxProgressValue: 100);
|
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
|
||||||
|
|
||||||
|
SetWorkingStatus($"Downloading {Info.Type} Test Mode package...", MaxProgressValue: 100);
|
||||||
|
|
||||||
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null);
|
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null);
|
||||||
|
|
||||||
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
||||||
@@ -788,19 +811,54 @@ namespace WPinternals
|
|||||||
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR
|
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR
|
||||||
|
|
||||||
BootModeFlagCommand[0x0F] = 0x59;
|
BootModeFlagCommand[0x0F] = 0x59;
|
||||||
((LumiaFlashAppModel)CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
((LumiaFlashAppModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
||||||
((LumiaFlashAppModel)CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
((LumiaFlashAppModel)PhoneNotifier.CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
||||||
ModeSwitchProgressWrapper("Rebooting phone to Label mode", null);
|
ModeSwitchProgressWrapper("Rebooting phone to Label mode", null);
|
||||||
LogFile.Log("Rebooting phone to Label mode", LogType.FileAndConsole);
|
LogFile.Log("Rebooting phone to Label mode", LogType.FileAndConsole);
|
||||||
}
|
}
|
||||||
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchFromFlashToLabelMode(bool Continuation = false)
|
private void SwitchFromFlashToLabelMode(bool Continuation = false)
|
||||||
{
|
{
|
||||||
string ProgressText = Continuation ? "And now preparing to boot the phone to Label mode..." : "Preparing to boot the phone to Label mode...";
|
string ProgressText = Continuation ? "And now preparing to boot the phone to Label mode..." : "Preparing to boot the phone to Label mode...";
|
||||||
|
|
||||||
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)CurrentModel;
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||||
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: true);
|
{
|
||||||
|
throw new WPinternalsException("Unexpected Mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneInfo Info = ((LumiaFlashAppModel)PhoneNotifier.CurrentModel).ReadPhoneInfo(ExtendedInfo: true);
|
||||||
|
|
||||||
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
((LumiaFlashAppModel)PhoneNotifier.CurrentModel).SwitchToPhoneInfoAppContext();
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||||
|
{
|
||||||
|
await PhoneNotifier.WaitForArrival();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_PhoneInfo)
|
||||||
|
{
|
||||||
|
throw new WPinternalsException("Unexpected Mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
PhoneInfo PhoneInfoAppInfo = ((LumiaPhoneInfoAppModel)PhoneNotifier.CurrentModel).ReadPhoneInfo(ExtendedInfo: true);
|
||||||
|
|
||||||
|
((LumiaPhoneInfoAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext();
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||||
|
{
|
||||||
|
await PhoneNotifier.WaitForArrival();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PhoneNotifier.CurrentInterface != PhoneInterfaces.Lumia_Flash)
|
||||||
|
{
|
||||||
|
throw new WPinternalsException("Unexpected Mode");
|
||||||
|
}
|
||||||
|
|
||||||
|
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
|
||||||
|
|
||||||
if (Info.MmosOverUsbSupported)
|
if (Info.MmosOverUsbSupported)
|
||||||
{
|
{
|
||||||
@@ -811,13 +869,18 @@ namespace WPinternals
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
ModeSwitchProgressWrapper(ProgressText, null);
|
ModeSwitchProgressWrapper(ProgressText, null);
|
||||||
|
|
||||||
string TempFolder = Environment.GetEnvironmentVariable("TEMP") + @"\WPInternals";
|
string TempFolder = Environment.GetEnvironmentVariable("TEMP") + @"\WPInternals";
|
||||||
if (Info.Type == "RM-1152")
|
|
||||||
|
if (PhoneInfoAppInfo.Type == "RM-1152")
|
||||||
{
|
{
|
||||||
Info.Type = "RM-1151";
|
PhoneInfoAppInfo.Type = "RM-1151";
|
||||||
}
|
}
|
||||||
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(Info.Type, Info.Firmware);
|
|
||||||
SetWorkingStatus("Downloading " + Info.Type + " Test Mode package...", MaxProgressValue: 100);
|
string ENOSWPackage = LumiaDownloadModel.SearchENOSW(PhoneInfoAppInfo.Type, Info.Firmware);
|
||||||
|
|
||||||
|
SetWorkingStatus($"Downloading {PhoneInfoAppInfo.Type} Test Mode package...", MaxProgressValue: 100);
|
||||||
|
|
||||||
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null);
|
DownloadEntry downloadEntry = new(ENOSWPackage, TempFolder, null, null, null);
|
||||||
|
|
||||||
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
downloadEntry.PropertyChanged += (object sender, System.ComponentModel.PropertyChangedEventArgs e) =>
|
||||||
@@ -867,21 +930,24 @@ namespace WPinternals
|
|||||||
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR
|
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52]; // NOKR
|
||||||
|
|
||||||
BootModeFlagCommand[0x0F] = 0x59;
|
BootModeFlagCommand[0x0F] = 0x59;
|
||||||
((LumiaFlashAppModel)CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
((LumiaFlashAppModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
||||||
((LumiaFlashAppModel)CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
((LumiaFlashAppModel)PhoneNotifier.CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
||||||
ModeSwitchProgressWrapper("Rebooting phone to Label mode", null);
|
ModeSwitchProgressWrapper("Rebooting phone to Label mode", null);
|
||||||
LogFile.Log("Rebooting phone to Label mode", LogType.FileAndConsole);
|
LogFile.Log("Rebooting phone to Label mode", LogType.FileAndConsole);
|
||||||
}
|
}
|
||||||
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void SwitchFromPhoneInfoToMassStorageMode(bool Continuation = false)
|
private void SwitchFromPhoneInfoToMassStorageMode(bool Continuation = false)
|
||||||
{
|
{
|
||||||
string ProgressText = Continuation ? "And now rebooting phone to Mass Storage mode..." : "Rebooting phone to Mass Storage mode...";
|
string ProgressText = Continuation ? "And now rebooting phone to Mass Storage mode..." : "Rebooting phone to Mass Storage mode...";
|
||||||
|
|
||||||
((LumiaBootManagerAppModel)CurrentModel).SwitchToFlashAppContext();
|
new Thread(async () =>
|
||||||
|
{
|
||||||
|
((LumiaPhoneInfoAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext();
|
||||||
await PhoneNotifier.WaitForArrival();
|
await PhoneNotifier.WaitForArrival();
|
||||||
|
|
||||||
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)CurrentModel;
|
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
|
||||||
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);
|
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);
|
||||||
|
|
||||||
MassStorageWarning = null;
|
MassStorageWarning = null;
|
||||||
@@ -914,17 +980,17 @@ namespace WPinternals
|
|||||||
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52];
|
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52];
|
||||||
byte[] RebootToMassStorageCommand = [0x4E, 0x4F, 0x4B, 0x4D]; // NOKM
|
byte[] RebootToMassStorageCommand = [0x4E, 0x4F, 0x4B, 0x4D]; // NOKM
|
||||||
IsSwitchingInterface = true;
|
IsSwitchingInterface = true;
|
||||||
byte[] RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToMassStorageCommand);
|
byte[] RebootCommandResult = ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(RebootToMassStorageCommand);
|
||||||
if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknown command)
|
if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknown command)
|
||||||
{
|
{
|
||||||
BootModeFlagCommand[0x0F] = 0x4D;
|
BootModeFlagCommand[0x0F] = 0x4D;
|
||||||
byte[] BootFlagResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
byte[] BootFlagResult = ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
||||||
UInt16 ResultCode = BitConverter.ToUInt16(BootFlagResult, 6);
|
UInt16 ResultCode = BitConverter.ToUInt16(BootFlagResult, 6);
|
||||||
if (ResultCode == 0)
|
if (ResultCode == 0)
|
||||||
{
|
{
|
||||||
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
||||||
|
|
||||||
((NokiaPhoneModel)CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
||||||
ModeSwitchProgressWrapper(ProgressText, MassStorageWarning);
|
ModeSwitchProgressWrapper(ProgressText, MassStorageWarning);
|
||||||
LogFile.Log("Rebooting phone to Mass Storage mode");
|
LogFile.Log("Rebooting phone to Mass Storage mode");
|
||||||
}
|
}
|
||||||
@@ -1073,6 +1139,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
ModeSwitchErrorWrapper("Bootloader was not unlocked. First unlock bootloader before you try to switch to Mass Storage Mode.");
|
ModeSwitchErrorWrapper("Bootloader was not unlocked. First unlock bootloader before you try to switch to Mass Storage Mode.");
|
||||||
}
|
}
|
||||||
|
}).Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SwitchFromFlashToMassStorageMode(bool Continuation = false)
|
private void SwitchFromFlashToMassStorageMode(bool Continuation = false)
|
||||||
@@ -1082,14 +1149,14 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
((LumiaBootManagerAppModel)CurrentModel).SwitchToFlashAppContext();
|
((LumiaBootManagerAppModel)PhoneNotifier.CurrentModel).SwitchToFlashAppContext();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogFile.LogException(ex, LogType.FileOnly);
|
LogFile.LogException(ex, LogType.FileOnly);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)CurrentModel;
|
LumiaFlashAppModel FlashModel = (LumiaFlashAppModel)PhoneNotifier.CurrentModel;
|
||||||
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);
|
PhoneInfo Info = FlashModel.ReadPhoneInfo(ExtendedInfo: false);
|
||||||
|
|
||||||
MassStorageWarning = null;
|
MassStorageWarning = null;
|
||||||
@@ -1122,17 +1189,17 @@ namespace WPinternals
|
|||||||
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52];
|
byte[] RebootCommand = [0x4E, 0x4F, 0x4B, 0x52];
|
||||||
byte[] RebootToMassStorageCommand = [0x4E, 0x4F, 0x4B, 0x4D]; // NOKM
|
byte[] RebootToMassStorageCommand = [0x4E, 0x4F, 0x4B, 0x4D]; // NOKM
|
||||||
IsSwitchingInterface = true;
|
IsSwitchingInterface = true;
|
||||||
byte[] RebootCommandResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(RebootToMassStorageCommand);
|
byte[] RebootCommandResult = ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(RebootToMassStorageCommand);
|
||||||
if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknown command)
|
if (RebootCommandResult?.Length == 4) // This means fail: NOKU (unknown command)
|
||||||
{
|
{
|
||||||
BootModeFlagCommand[0x0F] = 0x4D;
|
BootModeFlagCommand[0x0F] = 0x4D;
|
||||||
byte[] BootFlagResult = ((NokiaPhoneModel)CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
byte[] BootFlagResult = ((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawMethod(BootModeFlagCommand);
|
||||||
UInt16 ResultCode = BitConverter.ToUInt16(BootFlagResult, 6);
|
UInt16 ResultCode = BitConverter.ToUInt16(BootFlagResult, 6);
|
||||||
if (ResultCode == 0)
|
if (ResultCode == 0)
|
||||||
{
|
{
|
||||||
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
PhoneNotifier.NewDeviceArrived += NewDeviceArrived;
|
||||||
|
|
||||||
((NokiaPhoneModel)CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
((NokiaPhoneModel)PhoneNotifier.CurrentModel).ExecuteRawVoidMethod(RebootCommand);
|
||||||
ModeSwitchProgressWrapper(ProgressText, MassStorageWarning);
|
ModeSwitchProgressWrapper(ProgressText, MassStorageWarning);
|
||||||
LogFile.Log("Rebooting phone to Mass Storage mode");
|
LogFile.Log("Rebooting phone to Mass Storage mode");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user