Skip to content

Commit

Permalink
Some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gus33000 committed Oct 12, 2024
1 parent 059b41f commit 51f659c
Show file tree
Hide file tree
Showing 50 changed files with 493 additions and 458 deletions.
1 change: 1 addition & 0 deletions WPinternals/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
using System.Threading;
using System.Windows;
using WPinternals.HelperClasses;
using WPinternals.Config;

namespace WPinternals
{
Expand Down
1 change: 1 addition & 0 deletions WPinternals/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using WPinternals.Config;
using WPinternals.HelperClasses;
using WPinternals.Models.UEFIApps.BootMgr;
using WPinternals.Models.UEFIApps.Flash;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
using System.Xml.Serialization;
using WPinternals.HelperClasses;

namespace WPinternals.WPinternalsConfig
namespace WPinternals.Config
{
public class EmergencyFileEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

using System.IO;

namespace WPinternals.WPinternalsConfig
namespace WPinternals.Config
{
public class FFUEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
using System;
using System.Xml.Serialization;

namespace WPinternals.WPinternalsConfig
namespace WPinternals.Config
{
public class FlashProfile
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
using System.Security.Cryptography;
using System.Windows;

namespace WPinternals
namespace WPinternals.Config
{
internal static class Registration
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

using System.IO;

namespace WPinternals
namespace WPinternals.Config
{
public class SecWimEntry
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
using System.Xml.Serialization;
using WPinternals.HelperClasses;

namespace WPinternals
namespace WPinternals.Config
{

public class WPinternalsConfig
Expand Down Expand Up @@ -65,7 +65,7 @@ internal void WriteConfig()
FileWriter.Close();
}

internal void SetProfile(string Type, string PlatformID, string ProductCode, string PhoneFirmware, string FfuFirmware, UInt32 FillSize, UInt32 HeaderSize, bool AssumeImageHeaderFallsInGap, bool AllocateAsyncBuffersOnPhone)
internal void SetProfile(string Type, string PlatformID, string ProductCode, string PhoneFirmware, string FfuFirmware, uint FillSize, uint HeaderSize, bool AssumeImageHeaderFallsInGap, bool AllocateAsyncBuffersOnPhone)
{
FlashProfile Profile = GetProfile(PlatformID, PhoneFirmware, FfuFirmware);
if (Profile == null)
Expand All @@ -91,7 +91,7 @@ internal void SetProfile(string Type, string PlatformID, string ProductCode, str

internal FlashProfile GetProfile(string PlatformID, string PhoneFirmware, string FfuFirmware = null)
{
return FlashProfiles.Find(p => string.Equals(p.PlatformID, PlatformID, StringComparison.CurrentCultureIgnoreCase) && string.Equals(p.PhoneFirmware, PhoneFirmware, StringComparison.CurrentCultureIgnoreCase) && ((FfuFirmware == null) || string.Equals(p.FfuFirmware, FfuFirmware, StringComparison.CurrentCultureIgnoreCase)));
return FlashProfiles.Find(p => string.Equals(p.PlatformID, PlatformID, StringComparison.CurrentCultureIgnoreCase) && string.Equals(p.PhoneFirmware, PhoneFirmware, StringComparison.CurrentCultureIgnoreCase) && (FfuFirmware == null || string.Equals(p.FfuFirmware, FfuFirmware, StringComparison.CurrentCultureIgnoreCase)));
}

public List<FlashProfile> FlashProfiles = [];
Expand All @@ -111,7 +111,7 @@ internal void AddFfuToRepository(string FFUPath)

internal void AddFfuToRepository(string FFUPath, string PlatformID, string FirmwareVersion, string OSVersion)
{
FFUEntry Entry = FFURepository.Find(e => (e.PlatformID == PlatformID) && (e.FirmwareVersion == FirmwareVersion) && string.Equals(e.Path, FFUPath, StringComparison.CurrentCultureIgnoreCase));
FFUEntry Entry = FFURepository.Find(e => e.PlatformID == PlatformID && e.FirmwareVersion == FirmwareVersion && string.Equals(e.Path, FFUPath, StringComparison.CurrentCultureIgnoreCase));
if (Entry == null)
{
LogFile.Log("Adding FFU to repository: " + FFUPath, LogType.FileAndConsole);
Expand Down Expand Up @@ -165,7 +165,7 @@ internal void RemoveFfuFromRepository(string FFUPath)

internal void AddSecWimToRepository(string SecWimPath, string FirmwareVersion)
{
SecWimEntry Entry = SecWimRepository.Find(e => (e.FirmwareVersion == FirmwareVersion) && string.Equals(e.Path, SecWimPath, StringComparison.CurrentCultureIgnoreCase));
SecWimEntry Entry = SecWimRepository.Find(e => e.FirmwareVersion == FirmwareVersion && string.Equals(e.Path, SecWimPath, StringComparison.CurrentCultureIgnoreCase));
if (Entry == null)
{
LogFile.Log("Adding Secure WIM to repository: " + SecWimPath, LogType.FileAndConsole);
Expand Down Expand Up @@ -213,8 +213,8 @@ internal void RemoveSecWimFromRepository(string SecWimPath)

internal void AddEmergencyToRepository(string Type, string ProgrammerPath, string PayloadPath)
{
EmergencyFileEntry Entry = EmergencyRepository.Find(e => (e.Type == Type) && string.Equals(e.ProgrammerPath, ProgrammerPath, StringComparison.CurrentCultureIgnoreCase));
if ((Entry != null) && (PayloadPath != null) && (!string.Equals(Entry.PayloadPath, PayloadPath, StringComparison.CurrentCultureIgnoreCase)))
EmergencyFileEntry Entry = EmergencyRepository.Find(e => e.Type == Type && string.Equals(e.ProgrammerPath, ProgrammerPath, StringComparison.CurrentCultureIgnoreCase));
if (Entry != null && PayloadPath != null && !string.Equals(Entry.PayloadPath, PayloadPath, StringComparison.CurrentCultureIgnoreCase))
{
LogFile.Log("Updating emergency payload path in repository: " + PayloadPath, LogType.FileAndConsole);
Entry.PayloadPath = PayloadPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@
// Some of the classes and functions in this file were found online.
// Where possible the original authors are referenced.

using WPinternals.HelperClasses;

namespace WPinternals
namespace WPinternals.HelperClasses
{
internal delegate void SetWorkingStatus(string Message, string SubMessage = null, ulong? MaxProgressValue = null, bool ShowAnimation = true, WPinternalsStatus Status = WPinternalsStatus.Undefined);
internal delegate void UpdateWorkingStatus(string Message, string SubMessage = null, ulong? CurrentProgressValue = null, WPinternalsStatus Status = WPinternalsStatus.Undefined);
Expand Down
2 changes: 1 addition & 1 deletion WPinternals/HelperClasses/Paragraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
namespace WPinternals.HelperClasses
{
// Overloaded Paragraph class to remove empty Run-elements, caused by auto-formatting new-lines in the XAML
// Use local:Paragraph in a FlowDocument
// Use helpers:Paragraph in a FlowDocument
// This correction only works at run-time
public class Paragraph : System.Windows.Documents.Paragraph
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ internal LumiaBootManagerPhoneInfo ReadPhoneInfoBootManager()

ushort SubblockLength = BigEndian.ToUInt16(Response, SubblockOffset + 0x01);
int SubblockPayloadOffset = SubblockOffset + 3;
byte SubblockVersion;
switch (SubblockID)
{
case 0x01:
Expand Down
3 changes: 2 additions & 1 deletion WPinternals/Models/UEFIApps/Flash/LumiaFlashAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.IO;
using System.Linq;
using WPinternals.HelperClasses;
using WPinternals.Terminal;

namespace WPinternals.Models.UEFIApps.Flash
{
Expand Down Expand Up @@ -443,7 +444,7 @@ public TerminalResponse GetTerminalResponse()
if (TerminalResponse?.Length > 0x20 && BigEndian.ToUInt32(TerminalResponse, 0x14) == TerminalResponse.Length - 0x18 && BitConverter.ToUInt32(TerminalResponse, 0x1C) == TerminalResponse.Length - 0x20)
{
// Parse Terminal Response from offset 0x18
return Terminal.Parse(TerminalResponse, 0x18);
return Terminal.Terminal.Parse(TerminalResponse, 0x18);
}
else
{
Expand Down
1 change: 1 addition & 0 deletions WPinternals/Models/UEFIApps/NokiaUEFIModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
// DEALINGS IN THE SOFTWARE.

using System;
using WPinternals.HelperClasses;

namespace WPinternals.Models.UEFIApps
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ internal LumiaPhoneInfoAppPhoneInfo ReadPhoneInfoPhoneInfoApp()

ushort SubblockLength = BigEndian.ToUInt16(Response, SubblockOffset + 0x01);
int SubblockPayloadOffset = SubblockOffset + 3;
byte SubblockVersion;
switch (SubblockID)
{
case 0x20:
Expand Down
6 changes: 3 additions & 3 deletions WPinternals/Terminal.cs → WPinternals/Terminal/Terminal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

using System;

namespace WPinternals
namespace WPinternals.Terminal
{
internal static class Terminal
{
Expand All @@ -29,13 +29,13 @@ public static TerminalResponse Parse(byte[] Buffer, int Offset)
TerminalResponse Response = new();

// Get root node
if (Buffer.Length >= (Offset + 8))
if (Buffer.Length >= Offset + 8)
{
int NodeNumber = BitConverter.ToInt32(Buffer, Offset);
int NodeSize = BitConverter.ToInt32(Buffer, Offset + 4);
int End = NodeSize + Offset + 8;
int Index = Offset + 8;
if ((NodeNumber == 0x10000) && (End <= Buffer.Length))
if (NodeNumber == 0x10000 && End <= Buffer.Length)
{
// Get subnodes
while (Index < End)
Expand Down
1 change: 1 addition & 0 deletions WPinternals/ViewModels/LumiaUnlockBootViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WPinternals.Config;
using WPinternals.HelperClasses;
using WPinternals.Models.UEFIApps.Flash;
using WPinternals.Models.UEFIApps.PhoneInfo;
Expand Down
1 change: 1 addition & 0 deletions WPinternals/ViewModels/LumiaV2UnlockBootViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
using System.IO.Compression;
using System.Linq;
using System.Threading.Tasks;
using WPinternals.Config;
using WPinternals.HelperClasses;
using WPinternals.Models.UEFIApps;
using WPinternals.Models.UEFIApps.BootMgr;
Expand Down
1 change: 1 addition & 0 deletions WPinternals/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
using System.Threading.Tasks;
using System.Windows.Input;
using WPinternals.HelperClasses;
using WPinternals.Config;

namespace WPinternals
{
Expand Down
3 changes: 2 additions & 1 deletion WPinternals/ViewModels/NokiaLabelViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using System.Collections.Generic;
using System.Threading;
using WPinternals.HelperClasses;
using WPinternals.Terminal;

namespace WPinternals
{
Expand Down Expand Up @@ -93,7 +94,7 @@ private void StartLoadDeviceInfo()
byte[] TerminalResponseBytes = CurrentModel.ExecuteJsonMethodAsBytes("TerminalChallenge", Params, "TerminalResponse");
if (TerminalResponseBytes != null)
{
TerminalResponse TerminalResponse = Terminal.Parse(TerminalResponseBytes, 0);
TerminalResponse TerminalResponse = Terminal.Terminal.Parse(TerminalResponseBytes, 0);
if (TerminalResponse != null)
{
PublicID = TerminalResponse.PublicId;
Expand Down
1 change: 1 addition & 0 deletions WPinternals/ViewModels/RegistrationViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

using System;
using System.Windows;
using WPinternals.Config;
using WPinternals.HelperClasses;

namespace WPinternals
Expand Down
9 changes: 5 additions & 4 deletions WPinternals/Views/About.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ DEALINGS IN THE SOFTWARE.
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WPinternals"
xmlns:helpers="clr-namespace:WPinternals.HelperClasses"
mc:Ignorable="d"
d:DesignWidth="700">
<UserControl.Resources>
Expand All @@ -39,9 +40,9 @@ DEALINGS IN THE SOFTWARE.
</Grid.ColumnDefinitions>
<Image Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" Source="{StaticResource LogoImageSource}" Margin="-10,0,0,0">
</Image>
<local:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,0,0,0" VerticalScrollBarVisibility="Auto" >
<helpers:FlowDocumentScrollViewerNoMouseWheel Grid.Column="1" Margin="20,0,0,0" VerticalScrollBarVisibility="Auto" >
<FlowDocument x:Name="Document" FontFamily="Segoe UI" FontSize="12" Loaded="Document_Loaded" TextAlignment="Left">
<local:Paragraph>
<helpers:Paragraph>
<Run Text="Windows Phone Internals" FontSize="18" FontWeight="Bold" Foreground="#FF3753A6" />
<LineBreak />
<Run>
Expand Down Expand Up @@ -88,9 +89,9 @@ DEALINGS IN THE SOFTWARE.
<Run Text="DiscUtils by Kenneth Bell (" />
<Hyperlink NavigateUri="https://github.com/DiscUtils/DiscUtils/blob/master/LICENSE.txt">license</Hyperlink>
<Run Text=")" />
</local:Paragraph>
</helpers:Paragraph>
</FlowDocument>
</local:FlowDocumentScrollViewerNoMouseWheel>
</helpers:FlowDocumentScrollViewerNoMouseWheel>
</Grid>
</Border>
</UserControl>
Loading

0 comments on commit 51f659c

Please sign in to comment.