Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8981fd02e9 | ||
|
|
16d3f95971 | ||
|
|
293c649edb | ||
|
|
88efc77887 | ||
|
|
dc6085f185 | ||
|
|
e2cbb9c6fc | ||
|
|
4b7b9621b4 | ||
|
|
96c42a29b5 | ||
|
|
742c89b9bf | ||
|
|
dbd303fd07 | ||
|
|
8d35be447a | ||
|
|
83c09bdc81 | ||
|
|
93a5064751 | ||
|
|
ef6a962a01 | ||
|
|
d32788198d | ||
|
|
7798dd1c34 | ||
|
|
57cd052d61 | ||
|
|
5eb523530c | ||
|
|
8a17b05398 | ||
|
|
dc5ac1e7d4 | ||
|
|
1d14d79fab | ||
|
|
846ea41883 | ||
|
|
452393aaa7 | ||
|
|
17bc763761 | ||
|
|
668a9b7fe2 | ||
|
|
8293c18406 | ||
|
|
48fbfa77df | ||
|
|
709c91cec5 | ||
|
|
611ad122f9 | ||
|
|
d8fd0aa516 | ||
|
|
7f3c8b1777 | ||
|
|
087457fa0d | ||
|
|
bb9f614e82 |
@@ -0,0 +1,60 @@
|
|||||||
|
name: Bug Report
|
||||||
|
description: Create a bug report to help improve WPinternals
|
||||||
|
labels: [bug]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Description
|
||||||
|
description: A clear and concise description of what the bug is.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Steps To Reproduce
|
||||||
|
description: Steps to reproduce the behavior.
|
||||||
|
placeholder: |
|
||||||
|
1. Go to '....'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See the error
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Expected behavior
|
||||||
|
description: A clear and concise description of what you expected to happen.
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
id: wpi-version
|
||||||
|
attributes:
|
||||||
|
label: WPinternals Version
|
||||||
|
description: What version of WPinternals are you using?
|
||||||
|
placeholder: v2.9.2
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Windows Version
|
||||||
|
description: What version of Windows are you using? Press <kbd>Win</kbd> + <kbd>Pause/Break</kbd> and copy.
|
||||||
|
placeholder: e.g. Windows 11 21H2 22000.132
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: Phone model
|
||||||
|
description: What phone model did you reproduce the bug on (if applicable)
|
||||||
|
placeholder: e.g. Lumia 950 XL (RM-1085)
|
||||||
|
validations:
|
||||||
|
required: false
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: Relevant Assets
|
||||||
|
description: |
|
||||||
|
A list of assets (logs, screenshots) relevant to this bug.
|
||||||
|
|
||||||
|
Tip: You can attach images or log files by clicking this area to highlight it and then dragging files in.
|
||||||
|
placeholder: |
|
||||||
|
To upload the log
|
||||||
|
- Copy the `WPinternals.log` files from `%ALLUSERSPROFILE%\WPinternals`
|
||||||
|
- Drag and drop them into this text area.
|
||||||
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
architecture: [x86, x64]
|
architecture: [x86, x64, arm64]
|
||||||
platform: [win]
|
platform: [win]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Install .NET SDK
|
- name: Install .NET SDK
|
||||||
uses: actions/setup-dotnet@v1
|
uses: actions/setup-dotnet@v1
|
||||||
with:
|
with:
|
||||||
dotnet-version: "5.0.101"
|
dotnet-version: "8.0.x"
|
||||||
|
|
||||||
- name: Add MSBuild to PATH
|
- name: Add MSBuild to PATH
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
uses: microsoft/setup-msbuild@v1.0.2
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
# Windows Phone Internals
|
||||||
|
|
||||||
|
Windows Phone Internals (WPinternals or WPI for short) is a tool designed to unlock the bootloader and/or secure boot of select Lumia devices made by Nokia and Microsoft.
|
||||||
|
Thanks to specifically crafted exploits/techniques the tool is able to disable Bootloader Security/SecureBoot on select Lumia models.
|
||||||
|
|
||||||
|
After unlocking your bootloader you will be able to notably perform the following actions:
|
||||||
|
|
||||||
|
- Boot other Operating Systems
|
||||||
|
- Enable Root Access (on select OS versions)
|
||||||
|
- Flash Custom ROMs
|
||||||
|
- Backup your current Windows Phone ROM
|
||||||
|
- Access your phone internal storage over USB
|
||||||
|
|
||||||
|
## Root Access
|
||||||
|
|
||||||
|
Root Access is a set of patches/hacks disabling security inside Windows Phone at its root. Kernel Security, Permission checks, application container security, deployment capability security and much gets disabled as part of enabling root access.
|
||||||
|
|
||||||
|
## How to get started?
|
||||||
|
|
||||||
|
The tool contains all the documentation you need to know more about the tool, we invite you to read the getting started section of the tool to know more.
|
||||||
|
|
||||||
|
## Where do I download the tool?
|
||||||
|
|
||||||
|
Here: https://github.com/ReneLergner/WPinternals/releases/latest
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
<Application
|
||||||
|
x:Class="RootAccessTestUWP.App"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:RootAccessTestUWP"
|
||||||
|
RequestedTheme="Dark">
|
||||||
|
|
||||||
|
</Application>
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.ApplicationModel;
|
||||||
|
using Windows.ApplicationModel.Activation;
|
||||||
|
using Windows.Foundation;
|
||||||
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
|
namespace RootAccessTestUWP
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides application-specific behavior to supplement the default Application class.
|
||||||
|
/// </summary>
|
||||||
|
sealed partial class App : Application
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes the singleton application object. This is the first line of authored code
|
||||||
|
/// executed, and as such is the logical equivalent of main() or WinMain().
|
||||||
|
/// </summary>
|
||||||
|
public App()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
this.Suspending += OnSuspending;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when the application is launched normally by the end user. Other entry points
|
||||||
|
/// will be used such as when the application is launched to open a specific file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">Details about the launch request and process.</param>
|
||||||
|
protected override void OnLaunched(LaunchActivatedEventArgs e)
|
||||||
|
{
|
||||||
|
Frame rootFrame = Window.Current.Content as Frame;
|
||||||
|
|
||||||
|
// Do not repeat app initialization when the Window already has content,
|
||||||
|
// just ensure that the window is active
|
||||||
|
if (rootFrame == null)
|
||||||
|
{
|
||||||
|
// Create a Frame to act as the navigation context and navigate to the first page
|
||||||
|
rootFrame = new Frame();
|
||||||
|
|
||||||
|
rootFrame.NavigationFailed += OnNavigationFailed;
|
||||||
|
|
||||||
|
if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
|
||||||
|
{
|
||||||
|
//TODO: Load state from previously suspended application
|
||||||
|
}
|
||||||
|
|
||||||
|
// Place the frame in the current Window
|
||||||
|
Window.Current.Content = rootFrame;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (e.PrelaunchActivated == false)
|
||||||
|
{
|
||||||
|
if (rootFrame.Content == null)
|
||||||
|
{
|
||||||
|
// When the navigation stack isn't restored navigate to the first page,
|
||||||
|
// configuring the new page by passing required information as a navigation
|
||||||
|
// parameter
|
||||||
|
rootFrame.Navigate(typeof(MainPage), e.Arguments);
|
||||||
|
}
|
||||||
|
// Ensure the current window is active
|
||||||
|
Window.Current.Activate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when Navigation to a certain page fails
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The Frame which failed navigation</param>
|
||||||
|
/// <param name="e">Details about the navigation failure</param>
|
||||||
|
void OnNavigationFailed(object sender, NavigationFailedEventArgs e)
|
||||||
|
{
|
||||||
|
throw new Exception("Failed to load Page " + e.SourcePageType.FullName);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when application execution is being suspended. Application state is saved
|
||||||
|
/// without knowing whether the application will be terminated or resumed with the contents
|
||||||
|
/// of memory still intact.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the suspend request.</param>
|
||||||
|
/// <param name="e">Details about the suspend request.</param>
|
||||||
|
private void OnSuspending(object sender, SuspendingEventArgs e)
|
||||||
|
{
|
||||||
|
var deferral = e.SuspendingOperation.GetDeferral();
|
||||||
|
//TODO: Save application state and stop any background activity
|
||||||
|
deferral.Complete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 2.9 KiB |
|
After Width: | Height: | Size: 1.6 KiB |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 1.4 KiB |
|
After Width: | Height: | Size: 3.1 KiB |
@@ -0,0 +1,89 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace RootAccessTestUWP
|
||||||
|
{
|
||||||
|
public static class Core
|
||||||
|
{
|
||||||
|
[DllImport("KERNELBASE.DLL", CharSet = CharSet.Unicode, SetLastError = true)]
|
||||||
|
private static extern int RegQueryValueEx(UIntPtr hKey, string lpValueName, int lpReserved, out Core.RegistryValueKind lpType, IntPtr lpData, ref int lpcbData);
|
||||||
|
|
||||||
|
[DllImport("KERNELBASE.DLL", CharSet = CharSet.Unicode)]
|
||||||
|
private static extern int RegOpenKeyEx(UIntPtr hKey, string subKey, int ulOptions, int samDesired, out UIntPtr hkResult);
|
||||||
|
|
||||||
|
[DllImport("KERNELBASE.DLL", SetLastError = true)]
|
||||||
|
private static extern int RegCloseKey(UIntPtr hKey);
|
||||||
|
|
||||||
|
internal static string RegReadStringValue(UIntPtr rootKey, string keyPath, string valueName)
|
||||||
|
{
|
||||||
|
UIntPtr hKey;
|
||||||
|
int num = Core.RegOpenKeyEx(rootKey, keyPath, 0, Core.KEY_READ, out hKey);
|
||||||
|
if (num != 0)
|
||||||
|
{
|
||||||
|
throw new COMException("Failed to open registry key", num);
|
||||||
|
}
|
||||||
|
int cb = 1024;
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal(cb);
|
||||||
|
Core.RegistryValueKind registryValueKind;
|
||||||
|
num = Core.RegQueryValueEx(hKey, valueName, 0, out registryValueKind, intPtr, ref cb);
|
||||||
|
if (num != 0)
|
||||||
|
{
|
||||||
|
throw new COMException("Failed to read registry value", num);
|
||||||
|
}
|
||||||
|
if (registryValueKind != Core.RegistryValueKind.String)
|
||||||
|
{
|
||||||
|
throw new Exception("Wrong registry value type");
|
||||||
|
}
|
||||||
|
string result = Marshal.PtrToStringUni(intPtr);
|
||||||
|
Core.RegCloseKey(hKey);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static uint RegReadDwordValue(UIntPtr rootKey, string keyPath, string valueName)
|
||||||
|
{
|
||||||
|
UIntPtr hKey;
|
||||||
|
int num = Core.RegOpenKeyEx(rootKey, keyPath, 0, Core.KEY_READ, out hKey);
|
||||||
|
if (num != 0)
|
||||||
|
{
|
||||||
|
throw new COMException("Failed to open registry key", num);
|
||||||
|
}
|
||||||
|
int cb = 1024;
|
||||||
|
IntPtr intPtr = Marshal.AllocHGlobal(cb);
|
||||||
|
Core.RegistryValueKind registryValueKind;
|
||||||
|
num = Core.RegQueryValueEx(hKey, valueName, 0, out registryValueKind, intPtr, ref cb);
|
||||||
|
if (num != 0)
|
||||||
|
{
|
||||||
|
throw new COMException("Failed to read registry value", num);
|
||||||
|
}
|
||||||
|
if (registryValueKind != Core.RegistryValueKind.DWord)
|
||||||
|
{
|
||||||
|
throw new Exception("Wrong registry value type");
|
||||||
|
}
|
||||||
|
uint result = (uint)Marshal.ReadInt32(intPtr);
|
||||||
|
Core.RegCloseKey(hKey);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static UIntPtr HKEY_CLASSES_ROOT = (UIntPtr)2147483648U;
|
||||||
|
|
||||||
|
public static UIntPtr HKEY_CURRENT_USER = (UIntPtr)2147483649U;
|
||||||
|
|
||||||
|
public static UIntPtr HKEY_LOCAL_MACHINE = (UIntPtr)2147483650U;
|
||||||
|
|
||||||
|
public static UIntPtr HKEY_USERS = (UIntPtr)2147483651U;
|
||||||
|
|
||||||
|
private static int KEY_READ = 131097;
|
||||||
|
|
||||||
|
public enum RegistryValueKind
|
||||||
|
{
|
||||||
|
Unknown,
|
||||||
|
String,
|
||||||
|
ExpandString,
|
||||||
|
Binary,
|
||||||
|
DWord,
|
||||||
|
MultiString = 7,
|
||||||
|
QWord = 11,
|
||||||
|
None = -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<Page
|
||||||
|
x:Class="RootAccessTestUWP.MainPage"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:local="using:RootAccessTestUWP"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
|
||||||
|
<TextBlock x:Name="TextBlock"
|
||||||
|
Margin="10"
|
||||||
|
HorizontalAlignment="Stretch"
|
||||||
|
TextWrapping="Wrap"
|
||||||
|
Text=""
|
||||||
|
VerticalAlignment="Stretch"
|
||||||
|
FontFamily="Courier New" />
|
||||||
|
</Grid>
|
||||||
|
</Page>
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices.WindowsRuntime;
|
||||||
|
using Windows.Foundation;
|
||||||
|
using Windows.Foundation.Collections;
|
||||||
|
using Windows.UI.Xaml;
|
||||||
|
using Windows.UI.Xaml.Controls;
|
||||||
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
|
using Windows.UI.Xaml.Data;
|
||||||
|
using Windows.UI.Xaml.Input;
|
||||||
|
using Windows.UI.Xaml.Media;
|
||||||
|
using Windows.UI.Xaml.Navigation;
|
||||||
|
|
||||||
|
// The Blank Page item template is documented at https://go.microsoft.com/fwlink/?LinkId=402352&clcid=0x409
|
||||||
|
|
||||||
|
namespace RootAccessTestUWP
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An empty page that can be used on its own or navigated to within a Frame.
|
||||||
|
/// </summary>
|
||||||
|
public sealed partial class MainPage : Page
|
||||||
|
{
|
||||||
|
public MainPage()
|
||||||
|
{
|
||||||
|
this.InitializeComponent();
|
||||||
|
|
||||||
|
TextBlock.Text = "Reading: HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PhoneProvisioner\\ColdBootDone" + Environment.NewLine + Environment.NewLine;
|
||||||
|
|
||||||
|
bool flag = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Core.RegReadDwordValue(Core.HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\PhoneProvisioner", "ColdBootDone");
|
||||||
|
flag = true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
TextBlock.Text = string.Concat(new string[]
|
||||||
|
{
|
||||||
|
TextBlock.Text,
|
||||||
|
"Success!",
|
||||||
|
Environment.NewLine,
|
||||||
|
Environment.NewLine,
|
||||||
|
"Root Access: Enabled"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TextBlock.Text = string.Concat(new string[]
|
||||||
|
{
|
||||||
|
TextBlock.Text,
|
||||||
|
"Failed!",
|
||||||
|
Environment.NewLine,
|
||||||
|
Environment.NewLine,
|
||||||
|
"Root Access: Disabled"
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<Package
|
||||||
|
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
|
||||||
|
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
|
||||||
|
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
|
||||||
|
IgnorableNamespaces="uap mp">
|
||||||
|
|
||||||
|
<Identity
|
||||||
|
Name="66bf96f4-f5ba-41f1-8ceb-ac4e9065ac52"
|
||||||
|
Publisher="CN=Rene"
|
||||||
|
Version="1.0.0.0" />
|
||||||
|
|
||||||
|
<mp:PhoneIdentity PhoneProductId="66bf96f4-f5ba-41f1-8ceb-ac4e9065ac52" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>
|
||||||
|
|
||||||
|
<Properties>
|
||||||
|
<DisplayName>RootAccessTestUWP</DisplayName>
|
||||||
|
<PublisherDisplayName>Rene</PublisherDisplayName>
|
||||||
|
<Logo>Assets\StoreLogo.png</Logo>
|
||||||
|
</Properties>
|
||||||
|
|
||||||
|
<Dependencies>
|
||||||
|
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.0.0" MaxVersionTested="10.0.0.0" />
|
||||||
|
</Dependencies>
|
||||||
|
|
||||||
|
<Resources>
|
||||||
|
<Resource Language="x-generate"/>
|
||||||
|
</Resources>
|
||||||
|
|
||||||
|
<Applications>
|
||||||
|
<Application Id="App"
|
||||||
|
Executable="$targetnametoken$.exe"
|
||||||
|
EntryPoint="RootAccessTestUWP.App">
|
||||||
|
<uap:VisualElements
|
||||||
|
DisplayName="RootAccessTestUWP"
|
||||||
|
Square150x150Logo="Assets\Square150x150Logo.png"
|
||||||
|
Square44x44Logo="Assets\Square44x44Logo.png"
|
||||||
|
Description="RootAccessTestUWP"
|
||||||
|
BackgroundColor="transparent">
|
||||||
|
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png"/>
|
||||||
|
<uap:SplashScreen Image="Assets\SplashScreen.png" />
|
||||||
|
</uap:VisualElements>
|
||||||
|
</Application>
|
||||||
|
</Applications>
|
||||||
|
|
||||||
|
<Capabilities>
|
||||||
|
<Capability Name="internetClient" />
|
||||||
|
</Capabilities>
|
||||||
|
</Package>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("RootAccessTestUWP")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("RootAccessTestUWP")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<!--
|
||||||
|
This file contains Runtime Directives used by .NET Native. The defaults here are suitable for most
|
||||||
|
developers. However, you can modify these parameters to modify the behavior of the .NET Native
|
||||||
|
optimizer.
|
||||||
|
|
||||||
|
Runtime Directives are documented at https://go.microsoft.com/fwlink/?LinkID=391919
|
||||||
|
|
||||||
|
To fully enable reflection for App1.MyClass and all of its public/private members
|
||||||
|
<Type Name="App1.MyClass" Dynamic="Required All"/>
|
||||||
|
|
||||||
|
To enable dynamic creation of the specific instantiation of AppClass<T> over System.Int32
|
||||||
|
<TypeInstantiation Name="App1.AppClass" Arguments="System.Int32" Activate="Required Public" />
|
||||||
|
|
||||||
|
Using the Namespace directive to apply reflection policy to all the types in a particular namespace
|
||||||
|
<Namespace Name="DataClasses.ViewModels" Serialize="All" />
|
||||||
|
-->
|
||||||
|
|
||||||
|
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
|
||||||
|
<Application>
|
||||||
|
<!--
|
||||||
|
An Assembly element with Name="*Application*" applies to all assemblies in
|
||||||
|
the application package. The asterisks are not wildcards.
|
||||||
|
-->
|
||||||
|
<Assembly Name="*Application*" Dynamic="Required All" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Add your application specific runtime directives here. -->
|
||||||
|
|
||||||
|
|
||||||
|
</Application>
|
||||||
|
</Directives>
|
||||||
@@ -0,0 +1,169 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||||
|
<ProjectGuid>{8B6AADBB-C750-492E-AF60-82F6323401CC}</ProjectGuid>
|
||||||
|
<OutputType>AppContainerExe</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>RootAccessTestUWP</RootNamespace>
|
||||||
|
<AssemblyName>RootAccessTestUWP</AssemblyName>
|
||||||
|
<DefaultLanguage>en-US</DefaultLanguage>
|
||||||
|
<TargetPlatformIdentifier>UAP</TargetPlatformIdentifier>
|
||||||
|
<TargetPlatformVersion Condition=" '$(TargetPlatformVersion)' == '' ">10.0.22000.0</TargetPlatformVersion>
|
||||||
|
<TargetPlatformMinVersion>10.0.10240.0</TargetPlatformMinVersion>
|
||||||
|
<MinimumVisualStudioVersion>14</MinimumVisualStudioVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<ProjectTypeGuids>{A5A43C5B-DE2A-4C0C-9213-0A381AF9435A};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||||
|
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
||||||
|
<AppxPackageSigningEnabled>false</AppxPackageSigningEnabled>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||||
|
<OutputPath>bin\x86\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x86</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\ARM\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM'">
|
||||||
|
<OutputPath>bin\ARM\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>ARM</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|ARM64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\ARM64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>ARM64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|ARM64'">
|
||||||
|
<OutputPath>bin\ARM64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>ARM64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||||
|
<OutputPath>bin\x64\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE;NETFX_CORE;WINDOWS_UWP</DefineConstants>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<NoWarn>;2008</NoWarn>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
|
<UseVSHostingProcess>false</UseVSHostingProcess>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<Prefer32Bit>true</Prefer32Bit>
|
||||||
|
<UseDotNetNativeToolchain>true</UseDotNetNativeToolchain>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup>
|
||||||
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="App.xaml.cs">
|
||||||
|
<DependentUpon>App.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Core.cs" />
|
||||||
|
<Compile Include="MainPage.xaml.cs">
|
||||||
|
<DependentUpon>MainPage.xaml</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<AppxManifest Include="Package.appxmanifest">
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</AppxManifest>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Properties\Default.rd.xml" />
|
||||||
|
<Content Include="Assets\LockScreenLogo.scale-200.png" />
|
||||||
|
<Content Include="Assets\SplashScreen.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square150x150Logo.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square44x44Logo.scale-200.png" />
|
||||||
|
<Content Include="Assets\Square44x44Logo.targetsize-24_altform-unplated.png" />
|
||||||
|
<Content Include="Assets\StoreLogo.png" />
|
||||||
|
<Content Include="Assets\Wide310x150Logo.scale-200.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ApplicationDefinition Include="App.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</ApplicationDefinition>
|
||||||
|
<Page Include="MainPage.xaml">
|
||||||
|
<Generator>MSBuild:Compile</Generator>
|
||||||
|
<SubType>Designer</SubType>
|
||||||
|
</Page>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.NETCore.UniversalWindowsPlatform">
|
||||||
|
<Version>6.2.13</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
|
<VisualStudioVersion>14.0</VisualStudioVersion>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\Microsoft\WindowsXaml\v$(VisualStudioVersion)\Microsoft.Windows.UI.Xaml.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
||||||
@@ -1518,10 +1518,10 @@ namespace SevenZip.Compression.LZMA
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static readonly string[] kMatchFinderIDs =
|
private static readonly string[] kMatchFinderIDs =
|
||||||
{
|
[
|
||||||
"BT2",
|
"BT2",
|
||||||
"BT4",
|
"BT4",
|
||||||
};
|
];
|
||||||
|
|
||||||
private static int FindMatchFinder(string s)
|
private static int FindMatchFinder(string s)
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -114,7 +114,7 @@ namespace WPinternals
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (args[1].ToLower().TrimStart(new char[] { '-', '/' }))
|
switch (args[1].ToLower().TrimStart(['-', '/']))
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
case "test":
|
case "test":
|
||||||
@@ -223,7 +223,11 @@ namespace WPinternals
|
|||||||
UIContext.Send(s => Notifier.Start(), null);
|
UIContext.Send(s => Notifier.Start(), null);
|
||||||
FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
FlashModel = (NokiaFlashModel)await SwitchModeViewModel.SwitchTo(Notifier, PhoneInterfaces.Lumia_Flash);
|
||||||
GPT GPT = FlashModel.ReadGPT(); // May throw NotSupportedException
|
GPT GPT = FlashModel.ReadGPT(); // May throw NotSupportedException
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(args[2]));
|
string DirPath = Path.GetDirectoryName(args[2]);
|
||||||
|
if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DirPath);
|
||||||
|
}
|
||||||
GPT.WritePartitions(args[2]);
|
GPT.WritePartitions(args[2]);
|
||||||
FlashModel.SwitchToFlashAppContext();
|
FlashModel.SwitchToFlashAppContext();
|
||||||
Notifier.Stop();
|
Notifier.Stop();
|
||||||
@@ -237,6 +241,35 @@ namespace WPinternals
|
|||||||
LogFile.EndAction("BackupGPT");
|
LogFile.EndAction("BackupGPT");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "convertgpt":
|
||||||
|
if (args.Length < 4)
|
||||||
|
{
|
||||||
|
throw new ArgumentException("Wrong number of arguments. Usage: WPinternals.exe -ConvertGPT <Path to GPT-file> <Path to xml-file>");
|
||||||
|
}
|
||||||
|
|
||||||
|
LogFile.BeginAction("ConvertGPT");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using var stream = File.OpenRead(args[2]);
|
||||||
|
byte[] GPTBuffer = new byte[34 * 0x200];
|
||||||
|
stream.Read(GPTBuffer, 0, 34 * 0x200);
|
||||||
|
GPT GPT = new(GPTBuffer);// May throw NotSupportedException
|
||||||
|
string DirPath = Path.GetDirectoryName(args[3]);
|
||||||
|
if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DirPath);
|
||||||
|
}
|
||||||
|
GPT.WritePartitions(args[3]);
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
LogFile.LogException(Ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
LogFile.EndAction("ConvertGPT");
|
||||||
|
}
|
||||||
|
break;
|
||||||
case "restoregpt":
|
case "restoregpt":
|
||||||
if (args.Length < 3)
|
if (args.Length < 3)
|
||||||
{
|
{
|
||||||
@@ -393,7 +426,11 @@ namespace WPinternals
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
string EfiPath = Path.Combine(args[3], Name);
|
string EfiPath = Path.Combine(args[3], Name);
|
||||||
Directory.CreateDirectory(Path.GetDirectoryName(EfiPath));
|
string DirPath = Path.GetDirectoryName(EfiPath);
|
||||||
|
if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(DirPath);
|
||||||
|
}
|
||||||
File.WriteAllBytes(EfiPath, EfiBinary);
|
File.WriteAllBytes(EfiPath, EfiBinary);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -1968,6 +2005,7 @@ namespace WPinternals
|
|||||||
LogFile.Log("WPinternals -ClearNV", LogType.ConsoleOnly);
|
LogFile.Log("WPinternals -ClearNV", LogType.ConsoleOnly);
|
||||||
LogFile.Log("WPinternals -ReadGPT", LogType.ConsoleOnly);
|
LogFile.Log("WPinternals -ReadGPT", LogType.ConsoleOnly);
|
||||||
LogFile.Log("WPinternals -BackupGPT <Path to xml-file>", LogType.ConsoleOnly);
|
LogFile.Log("WPinternals -BackupGPT <Path to xml-file>", LogType.ConsoleOnly);
|
||||||
|
LogFile.Log("WPinternals -ConvertGPT <Path to GPT-file> <Path to xml-file>", LogType.ConsoleOnly);
|
||||||
LogFile.Log("WPinternals -RestoreGPT <Path to xml-file>", LogType.ConsoleOnly);
|
LogFile.Log("WPinternals -RestoreGPT <Path to xml-file>", LogType.ConsoleOnly);
|
||||||
LogFile.Log("WPinternals -MergeGPT <Path to input-xml-file> <Path to input-xml-file>", LogType.ConsoleOnly);
|
LogFile.Log("WPinternals -MergeGPT <Path to input-xml-file> <Path to input-xml-file>", LogType.ConsoleOnly);
|
||||||
LogFile.Log(" <Optional: Path to output-xml-file>", LogType.ConsoleOnly);
|
LogFile.Log(" <Optional: Path to output-xml-file>", LogType.ConsoleOnly);
|
||||||
@@ -68,7 +68,7 @@ namespace DiscUtils.Internal
|
|||||||
result.Add(func(sVal));
|
result.Add(func(sVal));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.ToArray();
|
return [.. result];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -31,15 +31,15 @@ namespace DiscUtils.Fat
|
|||||||
private const byte SpaceByte = 0x20;
|
private const byte SpaceByte = 0x20;
|
||||||
|
|
||||||
public static readonly FileName SelfEntryName =
|
public static readonly FileName SelfEntryName =
|
||||||
new(new byte[] { 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }, 0);
|
new([0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20], 0);
|
||||||
|
|
||||||
public static readonly FileName ParentEntryName =
|
public static readonly FileName ParentEntryName =
|
||||||
new(new byte[] { 0x2E, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20 }, 0);
|
new([0x2E, 0x2E, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20], 0);
|
||||||
|
|
||||||
public static readonly FileName Null =
|
public static readonly FileName Null =
|
||||||
new(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, 0);
|
new([0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00], 0);
|
||||||
|
|
||||||
private static readonly byte[] InvalidBytes = { 0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, 0x7C };
|
private static readonly byte[] InvalidBytes = [0x22, 0x2A, 0x2B, 0x2C, 0x2E, 0x2F, 0x3A, 0x3B, 0x3C, 0x3D, 0x3E, 0x3F, 0x5B, 0x5C, 0x5D, 0x7C];
|
||||||
|
|
||||||
private readonly byte[] _raw;
|
private readonly byte[] _raw;
|
||||||
|
|
||||||
@@ -33,10 +33,10 @@ namespace DiscUtils.Fat
|
|||||||
{
|
{
|
||||||
if (FatFileSystem.Detect(stream))
|
if (FatFileSystem.Detect(stream))
|
||||||
{
|
{
|
||||||
return new FileSystemInfo[] { new VfsFileSystemInfo("FAT", "Microsoft FAT", Open) };
|
return [new VfsFileSystemInfo("FAT", "Microsoft FAT", Open)];
|
||||||
}
|
}
|
||||||
|
|
||||||
return System.Array.Empty<FileSystemInfo>();
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
private DiscFileSystem Open(Stream stream, VolumeInfo volumeInfo, FileSystemParameters parameters)
|
private DiscFileSystem Open(Stream stream, VolumeInfo volumeInfo, FileSystemParameters parameters)
|
||||||
@@ -80,22 +80,22 @@ namespace DiscUtils.Fat
|
|||||||
{
|
{
|
||||||
// see http://home.teleport.com/~brainy/lfn.htm
|
// see http://home.teleport.com/~brainy/lfn.htm
|
||||||
// NOTE: we assume ordinals are ok here.
|
// NOTE: we assume ordinals are ok here.
|
||||||
char[] chars = new char[13];
|
char[] chars =
|
||||||
chars[0] = (char)((256 * buffer[2]) + buffer[1]);
|
[
|
||||||
chars[1] = (char)((256 * buffer[4]) + buffer[3]);
|
(char)((256 * buffer[2]) + buffer[1]),
|
||||||
chars[2] = (char)((256 * buffer[6]) + buffer[5]);
|
(char)((256 * buffer[4]) + buffer[3]),
|
||||||
chars[3] = (char)((256 * buffer[8]) + buffer[7]);
|
(char)((256 * buffer[6]) + buffer[5]),
|
||||||
chars[4] = (char)((256 * buffer[10]) + buffer[9]);
|
(char)((256 * buffer[8]) + buffer[7]),
|
||||||
|
(char)((256 * buffer[10]) + buffer[9]),
|
||||||
chars[5] = (char)((256 * buffer[15]) + buffer[14]);
|
(char)((256 * buffer[15]) + buffer[14]),
|
||||||
chars[6] = (char)((256 * buffer[17]) + buffer[16]);
|
(char)((256 * buffer[17]) + buffer[16]),
|
||||||
chars[7] = (char)((256 * buffer[19]) + buffer[18]);
|
(char)((256 * buffer[19]) + buffer[18]),
|
||||||
chars[8] = (char)((256 * buffer[21]) + buffer[20]);
|
(char)((256 * buffer[21]) + buffer[20]),
|
||||||
chars[9] = (char)((256 * buffer[23]) + buffer[22]);
|
(char)((256 * buffer[23]) + buffer[22]),
|
||||||
chars[10] = (char)((256 * buffer[25]) + buffer[24]);
|
(char)((256 * buffer[25]) + buffer[24]),
|
||||||
|
(char)((256 * buffer[29]) + buffer[28]),
|
||||||
chars[11] = (char)((256 * buffer[29]) + buffer[28]);
|
(char)((256 * buffer[31]) + buffer[30]),
|
||||||
chars[12] = (char)((256 * buffer[31]) + buffer[30]);
|
];
|
||||||
string chunk = new(chars);
|
string chunk = new(chars);
|
||||||
int zero = chunk.IndexOf('\0');
|
int zero = chunk.IndexOf('\0');
|
||||||
return zero >= 0 ? chunk.Substring(0, zero) : chunk;
|
return zero >= 0 ? chunk.Substring(0, zero) : chunk;
|
||||||
@@ -201,7 +201,7 @@ namespace DiscUtils.Fat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dirs.ToArray();
|
return [.. dirs];
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryEntry[] GetFiles()
|
public DirectoryEntry[] GetFiles()
|
||||||
@@ -215,7 +215,7 @@ namespace DiscUtils.Fat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.ToArray();
|
return [.. files];
|
||||||
}
|
}
|
||||||
|
|
||||||
public DirectoryEntry GetEntry(long id)
|
public DirectoryEntry GetEntry(long id)
|
||||||
@@ -1258,7 +1258,7 @@ namespace DiscUtils.Fat
|
|||||||
dirs.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
dirs.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return dirs.ToArray();
|
return [.. dirs];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1275,7 +1275,7 @@ namespace DiscUtils.Fat
|
|||||||
|
|
||||||
List<string> dirs = new();
|
List<string> dirs = new();
|
||||||
DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false);
|
DoSearch(dirs, path, re, searchOption == SearchOption.AllDirectories, true, false);
|
||||||
return dirs.ToArray();
|
return [.. dirs];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1294,7 +1294,7 @@ namespace DiscUtils.Fat
|
|||||||
files.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
files.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return files.ToArray();
|
return [.. files];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1311,7 +1311,7 @@ namespace DiscUtils.Fat
|
|||||||
|
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true);
|
DoSearch(results, path, re, searchOption == SearchOption.AllDirectories, false, true);
|
||||||
return results.ToArray();
|
return [.. results];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1330,7 +1330,7 @@ namespace DiscUtils.Fat
|
|||||||
result.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
result.Add(Utilities.CombinePaths(path, dirEntry.Name.GetDisplayName(FatOptions.FileNameEncoding)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.ToArray();
|
return [.. result];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1356,7 +1356,7 @@ namespace DiscUtils.Fat
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result.ToArray();
|
return [.. result];
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1915,9 +1915,7 @@ namespace DiscUtils.Fat
|
|||||||
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "The directory '{0}' was not found", path));
|
throw new DirectoryNotFoundException(string.Format(CultureInfo.InvariantCulture, "The directory '{0}' was not found", path));
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectoryEntry[] entries = dir.Entries;
|
foreach (DirectoryEntry de in dir.Entries)
|
||||||
|
|
||||||
foreach (DirectoryEntry de in entries)
|
|
||||||
{
|
{
|
||||||
bool isDir = (de.Attributes & FatAttributes.Directory) != 0;
|
bool isDir = (de.Attributes & FatAttributes.Directory) != 0;
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files (the "Software"),
|
copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -28,6 +28,7 @@ using System.Globalization;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@@ -658,7 +659,7 @@ namespace WPinternals
|
|||||||
Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString() + "." +
|
Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString() + "." +
|
||||||
Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + "." +
|
Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + "." +
|
||||||
Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString(), LogType.FileAndConsole);
|
Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString(), LogType.FileAndConsole);
|
||||||
Log("Copyright Heathcliff74 / wpinternals.net", LogType.FileAndConsole);
|
Log("Copyright Heathcliff74", LogType.FileAndConsole);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void BeginAction(string Action)
|
internal static void BeginAction(string Action)
|
||||||
@@ -673,7 +674,7 @@ namespace WPinternals
|
|||||||
Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString() + "." +
|
Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString() + "." +
|
||||||
Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + "." +
|
Assembly.GetExecutingAssembly().GetName().Version.Build.ToString() + "." +
|
||||||
Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString());
|
Assembly.GetExecutingAssembly().GetName().Version.Revision.ToString());
|
||||||
LogBuilder.AppendLine("Copyright Heathcliff74 / wpinternals.net");
|
LogBuilder.AppendLine("Copyright Heathcliff74");
|
||||||
LogBuilder.AppendLine("Action: " + Action);
|
LogBuilder.AppendLine("Action: " + Action);
|
||||||
if (App.Config.RegistrationName != null)
|
if (App.Config.RegistrationName != null)
|
||||||
LogBuilder.AppendLine("Name: " + App.Config.RegistrationName);
|
LogBuilder.AppendLine("Name: " + App.Config.RegistrationName);
|
||||||
@@ -924,7 +925,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
if (proxy?.CheckAccess() == false)
|
if (proxy?.CheckAccess() == false)
|
||||||
{
|
{
|
||||||
proxy.BeginInvoke(new Action<object, EventHandler>(CallHandler), new object[] { sender, eventHandler });
|
proxy.BeginInvoke(new Action<object, EventHandler>(CallHandler), [sender, eventHandler]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1890,7 +1891,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
internal static Version GetFileVersion(byte[] PEfile)
|
internal static Version GetFileVersion(byte[] PEfile)
|
||||||
{
|
{
|
||||||
byte[] version = GetResource(PEfile, new int[] { (int)ResourceType.RT_VERSION, 1, 1033 });
|
byte[] version = GetResource(PEfile, [(int)ResourceType.RT_VERSION, 1, 1033]);
|
||||||
|
|
||||||
// RT_VERSION format:
|
// RT_VERSION format:
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx
|
||||||
@@ -1906,7 +1907,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
internal static Version GetProductVersion(byte[] PEfile)
|
internal static Version GetProductVersion(byte[] PEfile)
|
||||||
{
|
{
|
||||||
byte[] version = GetResource(PEfile, new int[] { (int)ResourceType.RT_VERSION, 1, 1033 });
|
byte[] version = GetResource(PEfile, [(int)ResourceType.RT_VERSION, 1, 1033]);
|
||||||
|
|
||||||
// RT_VERSION format:
|
// RT_VERSION format:
|
||||||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx
|
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms647001(v=vs.85).aspx
|
||||||
@@ -1940,7 +1941,8 @@ namespace WPinternals
|
|||||||
|
|
||||||
internal static void Upload(string FileName, Stream FileStream)
|
internal static void Upload(string FileName, Stream FileStream)
|
||||||
{
|
{
|
||||||
Upload(new Uri(@"https://www.wpinternals.net/upload.php", UriKind.Absolute), "uploadedfile", FileName, FileStream);
|
//TODO: Fix
|
||||||
|
//Upload(new Uri(@"https://www.wpinternals.net/upload.php", UriKind.Absolute), "uploadedfile", FileName, FileStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void Upload(Uri Address, string InputName, string FileName, Stream FileStream)
|
private static void Upload(Uri Address, string InputName, string FileName, Stream FileStream)
|
||||||
@@ -2221,8 +2223,7 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
double width = Math.Max(allowedSpace * (Percentage / totalPercentage), 0);
|
_element.Width = (double)Math.Max(allowedSpace * (Percentage / totalPercentage), 0);
|
||||||
_element.Width = width;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 9.9 KiB After Width: | Height: | Size: 9.9 KiB |
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 75 KiB |
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -332,7 +332,7 @@ namespace WPinternals
|
|||||||
return (UInt16)(0x10000 - Checksum);
|
return (UInt16)(0x10000 - Checksum);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static readonly UInt32[] CRC32Table = new UInt32[] {
|
private static readonly UInt32[] CRC32Table = [
|
||||||
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F,
|
||||||
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
0xE963A535, 0x9E6495A3, 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
|
||||||
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
|
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, 0x1DB71064, 0x6AB020F2,
|
||||||
@@ -376,7 +376,7 @@ namespace WPinternals
|
|||||||
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
|
0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693,
|
||||||
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
0x54DE5729, 0x23D967BF, 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,
|
||||||
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D
|
||||||
};
|
];
|
||||||
|
|
||||||
internal static UInt32 CRC32(byte[] Input, UInt32 Offset, UInt32 Length)
|
internal static UInt32 CRC32(byte[] Input, UInt32 Offset, UInt32 Length)
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -84,7 +84,7 @@ namespace WPinternals
|
|||||||
// Read Store Header
|
// Read Store Header
|
||||||
byte[] ShortStoreHeader = new byte[248];
|
byte[] ShortStoreHeader = new byte[248];
|
||||||
FFUFile.Read(ShortStoreHeader, 0, 248);
|
FFUFile.Read(ShortStoreHeader, 0, 248);
|
||||||
PlatformID = ByteOperations.ReadAsciiString(ShortStoreHeader, 0x0C, 192).TrimEnd(new char[] { (char)0, ' ' });
|
PlatformID = ByteOperations.ReadAsciiString(ShortStoreHeader, 0x0C, 192).TrimEnd([(char)0, ' ']);
|
||||||
int WriteDescriptorCount = ByteOperations.ReadInt32(ShortStoreHeader, 208);
|
int WriteDescriptorCount = ByteOperations.ReadInt32(ShortStoreHeader, 208);
|
||||||
UInt32 WriteDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 212);
|
UInt32 WriteDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 212);
|
||||||
UInt32 ValidateDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 220);
|
UInt32 ValidateDescriptorLength = ByteOperations.ReadUInt32(ShortStoreHeader, 220);
|
||||||
@@ -455,8 +455,8 @@ namespace WPinternals
|
|||||||
if (Offset != null)
|
if (Offset != null)
|
||||||
{
|
{
|
||||||
uint Start = (uint)Offset + 10;
|
uint Start = (uint)Offset + 10;
|
||||||
uint Length = (uint)ByteOperations.FindPattern(Data, Start, 0x100, new byte[] { 0x00 }, null, null) - Start;
|
uint Length = (uint)ByteOperations.FindPattern(Data, Start, 0x100, [0x00], null, null) - Start;
|
||||||
uint? Offset0D = ByteOperations.FindPattern(Data, Start, 0x100, new byte[] { 0x0D }, null, null);
|
uint? Offset0D = ByteOperations.FindPattern(Data, Start, 0x100, [0x0D], null, null);
|
||||||
if ((Offset0D != null) && (Offset0D < (Start + Length)))
|
if ((Offset0D != null) && (Offset0D < (Start + Length)))
|
||||||
{
|
{
|
||||||
Length = (uint)Offset0D - Start;
|
Length = (uint)Offset0D - Start;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -74,7 +74,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
while (PartitionOffset < (TableOffset + TableSize))
|
while (PartitionOffset < (TableOffset + TableSize))
|
||||||
{
|
{
|
||||||
string Name = ByteOperations.ReadUnicodeString(GPTBuffer, PartitionOffset + 0x38, 0x48).TrimEnd(new char[] { (char)0, ' ' });
|
string Name = ByteOperations.ReadUnicodeString(GPTBuffer, PartitionOffset + 0x38, 0x48).TrimEnd([(char)0, ' ']);
|
||||||
if (Name.Length == 0)
|
if (Name.Length == 0)
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
@@ -545,7 +545,7 @@ namespace WPinternals
|
|||||||
internal void WritePartitions(string Path)
|
internal void WritePartitions(string Path)
|
||||||
{
|
{
|
||||||
string DirPath = System.IO.Path.GetDirectoryName(Path);
|
string DirPath = System.IO.Path.GetDirectoryName(Path);
|
||||||
if (!Directory.Exists(DirPath))
|
if (!string.IsNullOrEmpty(DirPath) && !Directory.Exists(DirPath))
|
||||||
{
|
{
|
||||||
Directory.CreateDirectory(DirPath);
|
Directory.CreateDirectory(DirPath);
|
||||||
}
|
}
|
||||||
@@ -559,6 +559,15 @@ namespace WPinternals
|
|||||||
FileWriter.Close();
|
FileWriter.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void WritePartitions(Stream Stream)
|
||||||
|
{
|
||||||
|
XmlSerializer x = new(typeof(GPT), "");
|
||||||
|
|
||||||
|
XmlSerializerNamespaces ns = new();
|
||||||
|
ns.Add("", "");
|
||||||
|
x.Serialize(Stream, this, ns);
|
||||||
|
}
|
||||||
|
|
||||||
internal static GPT ReadPartitions(string Path)
|
internal static GPT ReadPartitions(string Path)
|
||||||
{
|
{
|
||||||
XmlSerializer x = new(typeof(GPT), "");
|
XmlSerializer x = new(typeof(GPT), "");
|
||||||
@@ -570,8 +579,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
// This is necessary, because the partitions and backup-partitions can exchange.
|
// This is necessary, because the partitions and backup-partitions can exchange.
|
||||||
// This may cause the startsector to be higher than the maximum allowed sector for flashing with a Lumia V1 programmer (hardcoded in programmer)
|
// This may cause the startsector to be higher than the maximum allowed sector for flashing with a Lumia V1 programmer (hardcoded in programmer)
|
||||||
List<string> RevisePartitions = new(new string[] { "SBL1", "SBL2", "SBL3", "UEFI", "TZ", "RPM", "WINSECAPP" });
|
foreach (string RevisePartitionName in (List<string>)(new(new string[] { "SBL1", "SBL2", "SBL3", "UEFI", "TZ", "RPM", "WINSECAPP" })))
|
||||||
foreach (string RevisePartitionName in RevisePartitions)
|
|
||||||
{
|
{
|
||||||
Partition RevisePartition = GetPartition(RevisePartitionName);
|
Partition RevisePartition = GetPartition(RevisePartitionName);
|
||||||
Partition ReviseBackupPartition = GetPartition("BACKUP_" + RevisePartitionName);
|
Partition ReviseBackupPartition = GetPartition("BACKUP_" + RevisePartitionName);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -110,9 +110,9 @@ namespace WPinternals
|
|||||||
if (DictionarySize != 0)
|
if (DictionarySize != 0)
|
||||||
{
|
{
|
||||||
Encoder.SetCoderProperties(
|
Encoder.SetCoderProperties(
|
||||||
new CoderPropID[8] {CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits,
|
[CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits,
|
||||||
CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker},
|
CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker],
|
||||||
new object[8] { DictionarySize, PosStateBits, LitContextBits, LitPosBits, Algorithm, NumFastBytes, MatchFinder, EndMarker });
|
[DictionarySize, PosStateBits, LitContextBits, LitPosBits, Algorithm, NumFastBytes, MatchFinder, EndMarker]);
|
||||||
}
|
}
|
||||||
|
|
||||||
Encoder.WriteCoderProperties(stream);
|
Encoder.WriteCoderProperties(stream);
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -386,7 +386,7 @@ namespace WPinternals
|
|||||||
Result.Add(Src);
|
Result.Add(Src);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.ToArray();
|
return [.. Result];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -41,8 +41,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ManagementObjectCollection coll = new ManagementObjectSearcher("select * from Win32_LogicalDisk").Get();
|
foreach (ManagementObject logical in new ManagementObjectSearcher("select * from Win32_LogicalDisk").Get())
|
||||||
foreach (ManagementObject logical in coll)
|
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Print(logical["Name"].ToString());
|
System.Diagnostics.Debug.Print(logical["Name"].ToString());
|
||||||
|
|
||||||
@@ -112,10 +111,10 @@ namespace WPinternals
|
|||||||
SerialDevice.EncodeCommands = false;
|
SerialDevice.EncodeCommands = false;
|
||||||
|
|
||||||
// This will succeed on new models
|
// This will succeed on new models
|
||||||
SerialDevice.SendData(new byte[] { 0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0 });
|
SerialDevice.SendData([0x7, 0x0, 0x0, 0x0, 0x8, 0x0, 0x0, 0x0]);
|
||||||
|
|
||||||
// This will succeed on old models
|
// This will succeed on old models
|
||||||
SerialDevice.SendData(new byte[] { 0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E });
|
SerialDevice.SendData([0x7E, 0xA, 0x0, 0x0, 0xB6, 0xB5, 0x7E]);
|
||||||
|
|
||||||
SerialDevice.Close();
|
SerialDevice.Close();
|
||||||
SerialDevice.Dispose();
|
SerialDevice.Dispose();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -80,7 +80,7 @@ namespace WPinternals
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return System.Text.Encoding.ASCII.GetString(Bytes).Trim(new char[] { '\0' });
|
return System.Text.Encoding.ASCII.GetString(Bytes).Trim(['\0']);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
@@ -193,7 +193,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
public TerminalResponse GetTerminalResponse()
|
public TerminalResponse GetTerminalResponse()
|
||||||
{
|
{
|
||||||
byte[] AsskMask = new byte[0x10] { 1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64 };
|
byte[] AsskMask = [1, 0, 16, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64];
|
||||||
byte[] Request = new byte[0xAC];
|
byte[] Request = new byte[0xAC];
|
||||||
const string Header = "NOKXFT";
|
const string Header = "NOKXFT";
|
||||||
Buffer.BlockCopy(System.Text.Encoding.ASCII.GetBytes(Header), 0, Request, 0, Header.Length);
|
Buffer.BlockCopy(System.Text.Encoding.ASCII.GetBytes(Header), 0, Request, 0, Header.Length);
|
||||||
@@ -206,8 +206,7 @@ namespace WPinternals
|
|||||||
if ((TerminalResponse?.Length > 0x20) && (BigEndian.ToUInt32(TerminalResponse, 0x14) == (TerminalResponse.Length - 0x18)) && (BitConverter.ToUInt32(TerminalResponse, 0x1C) == (TerminalResponse.Length - 0x20)))
|
if ((TerminalResponse?.Length > 0x20) && (BigEndian.ToUInt32(TerminalResponse, 0x14) == (TerminalResponse.Length - 0x18)) && (BitConverter.ToUInt32(TerminalResponse, 0x1C) == (TerminalResponse.Length - 0x20)))
|
||||||
{
|
{
|
||||||
// Parse Terminal Response from offset 0x18
|
// Parse Terminal Response from offset 0x18
|
||||||
TerminalResponse ParsedResponse = Terminal.Parse(TerminalResponse, 0x18);
|
return Terminal.Parse(TerminalResponse, 0x18);
|
||||||
return ParsedResponse;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -973,7 +972,7 @@ namespace WPinternals
|
|||||||
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
Result.EmmcSizeInSectors = BigEndian.ToUInt32(Response, SubblockPayloadOffset);
|
||||||
break;
|
break;
|
||||||
case 0x05:
|
case 0x05:
|
||||||
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim(new char[] { ' ', '\0' });
|
Result.PlatformID = ByteOperations.ReadAsciiString(Response, (uint)SubblockPayloadOffset, SubblockLength).Trim([' ', '\0']);
|
||||||
break;
|
break;
|
||||||
case 0x0D:
|
case 0x0D:
|
||||||
Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1;
|
Result.AsyncSupport = Response[SubblockPayloadOffset + 1] == 1;
|
||||||
@@ -1216,8 +1215,7 @@ namespace WPinternals
|
|||||||
ByteOperations.WriteAsciiString(Request, 0, "NOKXPH" + VariableName + "\0"); // BTR or CTR, CTR is public ProductCode
|
ByteOperations.WriteAsciiString(Request, 0, "NOKXPH" + VariableName + "\0"); // BTR or CTR, CTR is public ProductCode
|
||||||
byte[] Response = ExecuteRawMethod(Request);
|
byte[] Response = ExecuteRawMethod(Request);
|
||||||
UInt16 Length = BigEndian.ToUInt16(Response, 6);
|
UInt16 Length = BigEndian.ToUInt16(Response, 6);
|
||||||
string Result = ByteOperations.ReadAsciiString(Response, 8, Length).Trim(new char[] { ' ', '\0' });
|
return ByteOperations.ReadAsciiString(Response, 8, Length).Trim([' ', '\0']);
|
||||||
return Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string ReadProductCode()
|
internal string ReadProductCode()
|
||||||
@@ -1373,7 +1371,7 @@ namespace WPinternals
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogFile.Log("SecureBoot: " + ((!PlatformSecureBootEnabled || !UefiSecureBootEnabled) ? "Disabled" : "Enabled") + " (Platform Secure Boot: " + (PlatformSecureBootEnabled ? "Enabled" : "Disabled") + ", UEFI Secure Boot: " + (PlatformSecureBootEnabled ? "Enabled" : "Disabled") + ")", Type);
|
LogFile.Log("SecureBoot: " + ((!PlatformSecureBootEnabled || !UefiSecureBootEnabled) ? "Disabled" : "Enabled") + " (Platform Secure Boot: " + (PlatformSecureBootEnabled ? "Enabled" : "Disabled") + ", UEFI Secure Boot: " + (UefiSecureBootEnabled ? "Enabled" : "Disabled") + ")", Type);
|
||||||
|
|
||||||
if ((Type == LogType.ConsoleOnly) || (Type == LogType.FileAndConsole))
|
if ((Type == LogType.ConsoleOnly) || (Type == LogType.FileAndConsole))
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -40,14 +40,14 @@ namespace WPinternals
|
|||||||
|
|
||||||
internal PatchEngine(string PatchDefinitionsXmlString)
|
internal PatchEngine(string PatchDefinitionsXmlString)
|
||||||
{
|
{
|
||||||
XmlSerializer x = new(PatchDefinitions.GetType(), null, Array.Empty<Type>(), new XmlRootAttribute("PatchDefinitions"), "");
|
XmlSerializer x = new(PatchDefinitions.GetType(), null, [], new XmlRootAttribute("PatchDefinitions"), "");
|
||||||
MemoryStream s = new(System.Text.Encoding.ASCII.GetBytes(PatchDefinitionsXmlString));
|
MemoryStream s = new(System.Text.Encoding.ASCII.GetBytes(PatchDefinitionsXmlString));
|
||||||
PatchDefinitions = (List<PatchDefinition>)x.Deserialize(s);
|
PatchDefinitions = (List<PatchDefinition>)x.Deserialize(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void WriteDefinitions(string FilePath)
|
internal void WriteDefinitions(string FilePath)
|
||||||
{
|
{
|
||||||
XmlSerializer x = new(PatchDefinitions.GetType(), null, Array.Empty<Type>(), new XmlRootAttribute("PatchDefinitions"), "");
|
XmlSerializer x = new(PatchDefinitions.GetType(), null, [], new XmlRootAttribute("PatchDefinitions"), "");
|
||||||
|
|
||||||
XmlSerializerNamespaces ns = new();
|
XmlSerializerNamespaces ns = new();
|
||||||
ns.Add("", "");
|
ns.Add("", "");
|
||||||
@@ -58,7 +58,7 @@ namespace WPinternals
|
|||||||
FileWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
FileWriter.WriteLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
|
||||||
FileWriter.WriteLine("");
|
FileWriter.WriteLine("");
|
||||||
FileWriter.WriteLine("<!--");
|
FileWriter.WriteLine("<!--");
|
||||||
FileWriter.WriteLine("Copyright(c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda");
|
FileWriter.WriteLine("Copyright(c) 2018, Rene Lergner - @Heathcliff74xda");
|
||||||
FileWriter.WriteLine("");
|
FileWriter.WriteLine("");
|
||||||
FileWriter.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a");
|
FileWriter.WriteLine("Permission is hereby granted, free of charge, to any person obtaining a");
|
||||||
FileWriter.WriteLine("copy of this software and associated documentation files(the \"Software\"),");
|
FileWriter.WriteLine("copy of this software and associated documentation files(the \"Software\"),");
|
||||||
@@ -94,7 +94,7 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_TargetPath = value.TrimEnd(new char[] { '\\' });
|
_TargetPath = value.TrimEnd(['\\']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -365,7 +365,7 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_RelativePath = value.TrimStart(new char[] { '\\' }).TrimEnd(new char[] { '\\' });
|
_RelativePath = value.TrimStart(['\\']).TrimEnd(['\\']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,7 +377,7 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_TargetPath = value.TrimEnd(new char[] { '\\' });
|
_TargetPath = value.TrimEnd(['\\']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -515,7 +515,7 @@ namespace WPinternals
|
|||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_Path = value.TrimStart(new char[] { '\\' });
|
_Path = value.TrimStart(['\\']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -37,7 +37,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Serial.SendCommand(new byte[] { 0x06 }, new byte[] { 0x02 });
|
Serial.SendCommand([0x06], [0x02]);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
@@ -61,7 +61,7 @@ namespace WPinternals
|
|||||||
CurrentLength = Remaining >= 0x100 ? 0x100 : (UInt32)Remaining;
|
CurrentLength = Remaining >= 0x100 ? 0x100 : (UInt32)Remaining;
|
||||||
|
|
||||||
CurrentLength = (UInt32)Data.Read(Buffer, 7, (int)CurrentLength);
|
CurrentLength = (UInt32)Data.Read(Buffer, 7, (int)CurrentLength);
|
||||||
Serial.SendCommand(Buffer, new byte[] { 0x02 });
|
Serial.SendCommand(Buffer, [0x02]);
|
||||||
|
|
||||||
CurrentAddress += CurrentLength;
|
CurrentAddress += CurrentLength;
|
||||||
Remaining -= CurrentLength;
|
Remaining -= CurrentLength;
|
||||||
@@ -100,7 +100,7 @@ namespace WPinternals
|
|||||||
System.Buffer.BlockCopy(BitConverter.GetBytes((UInt16)CurrentLength).Reverse().ToArray(), 0, CurrentBytes, 5, 2); // Length is in Big Endian
|
System.Buffer.BlockCopy(BitConverter.GetBytes((UInt16)CurrentLength).Reverse().ToArray(), 0, CurrentBytes, 5, 2); // Length is in Big Endian
|
||||||
System.Buffer.BlockCopy(Data, (int)CurrentOffset, CurrentBytes, 7, (int)CurrentLength);
|
System.Buffer.BlockCopy(Data, (int)CurrentOffset, CurrentBytes, 7, (int)CurrentLength);
|
||||||
|
|
||||||
Serial.SendCommand(CurrentBytes, new byte[] { 0x02 });
|
Serial.SendCommand(CurrentBytes, [0x02]);
|
||||||
|
|
||||||
CurrentAddress += CurrentLength;
|
CurrentAddress += CurrentLength;
|
||||||
CurrentOffset += CurrentLength;
|
CurrentOffset += CurrentLength;
|
||||||
@@ -113,25 +113,25 @@ namespace WPinternals
|
|||||||
byte[] Buffer = new byte[5];
|
byte[] Buffer = new byte[5];
|
||||||
Buffer[0] = 0x05;
|
Buffer[0] = 0x05;
|
||||||
System.Buffer.BlockCopy(BitConverter.GetBytes(Address).Reverse().ToArray(), 0, Buffer, 1, 4); // Address is in Big Endian
|
System.Buffer.BlockCopy(BitConverter.GetBytes(Address).Reverse().ToArray(), 0, Buffer, 1, 4); // Address is in Big Endian
|
||||||
Serial.SendCommand(Buffer, new byte[] { 0x02 });
|
Serial.SendCommand(Buffer, [0x02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset interface. Interface becomes unresponsive.
|
// Reset interface. Interface becomes unresponsive.
|
||||||
public void Reset()
|
public void Reset()
|
||||||
{
|
{
|
||||||
Serial.SendCommand(new byte[] { 0x0A }, new byte[] { 0x02 });
|
Serial.SendCommand([0x0A], [0x02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This also resets interface. This does not actually reboot the phone. The interface becomes unresponsive.
|
// This also resets interface. This does not actually reboot the phone. The interface becomes unresponsive.
|
||||||
public void Shutdown()
|
public void Shutdown()
|
||||||
{
|
{
|
||||||
Serial.SendCommand(new byte[] { 0x0E }, new byte[] { 0x02 });
|
Serial.SendCommand([0x0E], [0x02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This command only works on 9008 interface.
|
// This command only works on 9008 interface.
|
||||||
public byte[] GetRKH()
|
public byte[] GetRKH()
|
||||||
{
|
{
|
||||||
byte[] Response = Serial.SendCommand(new byte[] { 0x18 }, new byte[] { 0x18, 0x01, 0x00 });
|
byte[] Response = Serial.SendCommand([0x18], [0x18, 0x01, 0x00]);
|
||||||
byte[] Result = new byte[0x20];
|
byte[] Result = new byte[0x20];
|
||||||
Buffer.BlockCopy(Response, 3, Result, 0, 0x20);
|
Buffer.BlockCopy(Response, 3, Result, 0, 0x20);
|
||||||
return Result;
|
return Result;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -28,165 +27,15 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace WPinternals
|
namespace WPinternals
|
||||||
{
|
{
|
||||||
internal enum SaharaMode : uint
|
internal class QualcommFirehose
|
||||||
{
|
|
||||||
ImageTransferPending = 0x00,
|
|
||||||
ImagetransferComplete = 0x01,
|
|
||||||
MemoryDebug = 0x02,
|
|
||||||
Command = 0x03
|
|
||||||
}
|
|
||||||
|
|
||||||
internal delegate void ReadyHandler();
|
|
||||||
|
|
||||||
internal class QualcommSahara
|
|
||||||
{
|
{
|
||||||
private readonly QualcommSerial Serial;
|
private readonly QualcommSerial Serial;
|
||||||
|
|
||||||
public QualcommSahara(QualcommSerial Serial)
|
public QualcommFirehose(QualcommSerial Serial)
|
||||||
{
|
{
|
||||||
Serial.EncodeCommands = false;
|
|
||||||
Serial.DecodeResponses = false;
|
|
||||||
this.Serial = Serial;
|
this.Serial = Serial;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool SendImage(string Path)
|
|
||||||
{
|
|
||||||
bool Result = true;
|
|
||||||
|
|
||||||
LogFile.Log("Sending programmer: " + Path, LogType.FileOnly);
|
|
||||||
|
|
||||||
int Step = 0;
|
|
||||||
UInt32 Offset = 0;
|
|
||||||
UInt32 Length = 0;
|
|
||||||
|
|
||||||
byte[] ImageBuffer = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Step = 1;
|
|
||||||
byte[] Hello = Serial.GetResponse(new byte[] { 0x01, 0x00, 0x00, 0x00 });
|
|
||||||
|
|
||||||
// Incoming Hello packet:
|
|
||||||
// 00000001 = Hello command id
|
|
||||||
// xxxxxxxx = Length
|
|
||||||
// xxxxxxxx = Protocol version
|
|
||||||
// xxxxxxxx = Supported version
|
|
||||||
// xxxxxxxx = Max packet length
|
|
||||||
// xxxxxxxx = Expected mode
|
|
||||||
// 6 dwords reserved space
|
|
||||||
LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly);
|
|
||||||
|
|
||||||
// Packet:
|
|
||||||
// 00000002 = Hello response command id
|
|
||||||
// 00000030 = Length
|
|
||||||
// 00000002 = Protocol version
|
|
||||||
// 00000001 = Supported version
|
|
||||||
// 00000000 = Status OK
|
|
||||||
// 00000000 = Mode
|
|
||||||
// rest is reserved space
|
|
||||||
Step = 2;
|
|
||||||
byte[] HelloResponse = new byte[] {
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
Serial.SendData(HelloResponse);
|
|
||||||
|
|
||||||
Step = 3;
|
|
||||||
using FileStream FileStream = new(Path, FileMode.Open, FileAccess.Read);
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
Step = 4;
|
|
||||||
byte[] ReadDataRequest = Serial.GetResponse(null);
|
|
||||||
UInt32 ResponseID = ByteOperations.ReadUInt32(ReadDataRequest, 0);
|
|
||||||
if (ResponseID == 4)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ResponseID != 3)
|
|
||||||
{
|
|
||||||
Step = 5;
|
|
||||||
throw new BadConnectionException();
|
|
||||||
}
|
|
||||||
|
|
||||||
Offset = ByteOperations.ReadUInt32(ReadDataRequest, 0x0C);
|
|
||||||
Length = ByteOperations.ReadUInt32(ReadDataRequest, 0x10);
|
|
||||||
if ((ImageBuffer == null) || (ImageBuffer.Length != Length))
|
|
||||||
{
|
|
||||||
ImageBuffer = new byte[Length];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (FileStream.Position != Offset)
|
|
||||||
{
|
|
||||||
FileStream.Seek(Offset, SeekOrigin.Begin);
|
|
||||||
}
|
|
||||||
|
|
||||||
Step = 6;
|
|
||||||
FileStream.Read(ImageBuffer, 0, (int)Length);
|
|
||||||
|
|
||||||
Step = 7;
|
|
||||||
Serial.SendData(ImageBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception Ex)
|
|
||||||
{
|
|
||||||
LogFile.LogException(Ex, LogType.FileAndConsole, Step.ToString() + " 0x" + Offset.ToString("X8") + " 0x" + Length.ToString("X8"));
|
|
||||||
Result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Result)
|
|
||||||
{
|
|
||||||
LogFile.Log("Programmer loaded into phone memory", LogType.FileOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Handshake()
|
|
||||||
{
|
|
||||||
bool Result = true;
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
byte[] Hello = Serial.GetResponse(new byte[] { 0x01, 0x00, 0x00, 0x00 });
|
|
||||||
|
|
||||||
// Incoming Hello packet:
|
|
||||||
// 00000001 = Hello command id
|
|
||||||
// xxxxxxxx = Length
|
|
||||||
// xxxxxxxx = Protocol version
|
|
||||||
// xxxxxxxx = Supported version
|
|
||||||
// xxxxxxxx = Max packet length
|
|
||||||
// xxxxxxxx = Expected mode
|
|
||||||
// 6 dwords reserved space
|
|
||||||
LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly);
|
|
||||||
LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly);
|
|
||||||
|
|
||||||
byte[] HelloResponse = new byte[] {
|
|
||||||
0x02, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
|
||||||
};
|
|
||||||
|
|
||||||
byte[] Ready = Serial.SendCommand(HelloResponse, new byte[] { 0x03, 0x00, 0x00, 0x00 });
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Result = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void ResetSahara()
|
|
||||||
{
|
|
||||||
Serial.SendCommand(new byte[] { 0x07, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 }, new byte[] { 0x08, 0x00, 0x00, 0x00 });
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ConnectToProgrammer(byte[] PacketFromPcToProgrammer)
|
public bool ConnectToProgrammer(byte[] PacketFromPcToProgrammer)
|
||||||
{
|
{
|
||||||
// Behaviour of old firehose:
|
// Behaviour of old firehose:
|
||||||
@@ -280,16 +129,8 @@ namespace WPinternals
|
|||||||
return HandshakeCompleted;
|
return HandshakeCompleted;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> Reset(string ProgrammerPath)
|
public async Task<bool> Reset()
|
||||||
{
|
{
|
||||||
bool SendImageResult = await Task.Run(() => SendImage(ProgrammerPath));
|
|
||||||
if (!SendImageResult)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
await Task.Run(() => StartProgrammer());
|
|
||||||
|
|
||||||
bool Connected = await Task.Run(() => ConnectToProgrammerInTestMode());
|
bool Connected = await Task.Run(() => ConnectToProgrammerInTestMode());
|
||||||
if (!Connected)
|
if (!Connected)
|
||||||
{
|
{
|
||||||
@@ -317,59 +158,12 @@ namespace WPinternals
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SwitchMode(SaharaMode Mode)
|
public bool SendEdPayload(string ProgrammerPath, string PayloadPath)
|
||||||
{
|
|
||||||
byte[] SwitchModeCommand = new byte[] { 0x0C, 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
||||||
ByteOperations.WriteUInt32(SwitchModeCommand, 8, (UInt32)Mode);
|
|
||||||
byte[] ResponsePattern = null;
|
|
||||||
switch (Mode)
|
|
||||||
{
|
|
||||||
case SaharaMode.ImageTransferPending:
|
|
||||||
ResponsePattern = new byte[] { 0x04, 0x00, 0x00, 0x00 };
|
|
||||||
break;
|
|
||||||
case SaharaMode.MemoryDebug:
|
|
||||||
ResponsePattern = new byte[] { 0x09, 0x00, 0x00, 0x00 };
|
|
||||||
break;
|
|
||||||
case SaharaMode.Command:
|
|
||||||
ResponsePattern = new byte[] { 0x0B, 0x00, 0x00, 0x00 };
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Serial.SendCommand(SwitchModeCommand, ResponsePattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void StartProgrammer()
|
|
||||||
{
|
|
||||||
LogFile.Log("Starting programmer", LogType.FileAndConsole);
|
|
||||||
byte[] DoneCommand = new byte[] { 0x05, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00 };
|
|
||||||
bool Started = false;
|
|
||||||
int count = 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
count++;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
byte[] DoneResponse = Serial.SendCommand(DoneCommand, new byte[] { 0x06, 0x00, 0x00, 0x00 });
|
|
||||||
Started = true;
|
|
||||||
}
|
|
||||||
catch (BadConnectionException)
|
|
||||||
{
|
|
||||||
LogFile.Log("Problem while starting programmer. Attempting again.", LogType.FileAndConsole);
|
|
||||||
}
|
|
||||||
} while (!Started && count < 3);
|
|
||||||
if (count >= 3 && !Started)
|
|
||||||
{
|
|
||||||
LogFile.Log("Maximum number of attempts to start the programmer exceeded.", LogType.FileAndConsole);
|
|
||||||
throw new BadConnectionException();
|
|
||||||
}
|
|
||||||
LogFile.Log("Programmer being launched on phone", LogType.FileOnly);
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task<bool> SendEdPayload(string ProgrammerPath, string PayloadPath)
|
|
||||||
{
|
{
|
||||||
// First, let's read the Emergency Download payload header and verify its validity
|
// First, let's read the Emergency Download payload header and verify its validity
|
||||||
FileStream PayloadStream = File.OpenRead(PayloadPath);
|
FileStream PayloadStream = File.OpenRead(PayloadPath);
|
||||||
|
|
||||||
byte[] ValidReferencePayloadHeader = new byte[] { 0x45, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x6E, 0x63, 0x79, 0x20, 0x50, 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64 };
|
byte[] ValidReferencePayloadHeader = [0x45, 0x6D, 0x65, 0x72, 0x67, 0x65, 0x6E, 0x63, 0x79, 0x20, 0x50, 0x61, 0x79, 0x6C, 0x6F, 0x61, 0x64];
|
||||||
|
|
||||||
byte[] PayloadHeader = new byte[17];
|
byte[] PayloadHeader = new byte[17];
|
||||||
PayloadStream.Read(PayloadHeader, 0, 17);
|
PayloadStream.Read(PayloadHeader, 0, 17);
|
||||||
@@ -405,16 +199,6 @@ namespace WPinternals
|
|||||||
LogFile.Log("Version: " + version, LogType.FileAndConsole);
|
LogFile.Log("Version: " + version, LogType.FileAndConsole);
|
||||||
LogFile.Log("Info: " + Info, LogType.FileAndConsole);
|
LogFile.Log("Info: " + Info, LogType.FileAndConsole);
|
||||||
|
|
||||||
// Send the emergency programmer to the phone
|
|
||||||
bool SendImageResult = await Task.Run(() => SendImage(ProgrammerPath));
|
|
||||||
if (!SendImageResult)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the emergency programmer on the phone
|
|
||||||
await Task.Run(() => StartProgrammer());
|
|
||||||
|
|
||||||
// Wait a few seconds before sending commands
|
// Wait a few seconds before sending commands
|
||||||
LogFile.Log("Waiting...", LogType.FileAndConsole);
|
LogFile.Log("Waiting...", LogType.FileAndConsole);
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
@@ -434,7 +218,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
LogFile.Log(ProgrammerCommand, LogType.FileAndConsole);
|
LogFile.Log(ProgrammerCommand, LogType.FileAndConsole);
|
||||||
|
|
||||||
byte[] PacketFromPcToProgrammer = Array.Empty<byte>();
|
byte[] PacketFromPcToProgrammer = [];
|
||||||
byte[] temp = new byte[0x200];
|
byte[] temp = new byte[0x200];
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
@@ -453,7 +237,7 @@ namespace WPinternals
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
PacketFromPcToProgrammer = PacketFromPcToProgrammer.Concat(temp).ToArray();
|
PacketFromPcToProgrammer = [.. PacketFromPcToProgrammer, .. temp];
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ExpectingReplyFromProgrammer = false;
|
bool ExpectingReplyFromProgrammer = false;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -45,41 +45,37 @@ namespace WPinternals
|
|||||||
|
|
||||||
public void Hello()
|
public void Hello()
|
||||||
{
|
{
|
||||||
byte[] Command = new byte[]
|
byte[] Command =
|
||||||
{
|
[
|
||||||
0x01, // Hello command
|
0x01, // Hello command
|
||||||
0x51, 0x43, 0x4F, 0x4D, 0x20, 0x66, 0x61, 0x73, 0x74, 0x20, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, // "QCOM fast download protocol host"
|
0x51, 0x43, 0x4F, 0x4D, 0x20, 0x66, 0x61, 0x73, 0x74, 0x20, 0x64, 0x6F, 0x77, 0x6E, 0x6C, 0x6F, // "QCOM fast download protocol host"
|
||||||
0x61, 0x64, 0x20, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x20, 0x68, 0x6F, 0x73, 0x74,
|
0x61, 0x64, 0x20, 0x70, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x20, 0x68, 0x6F, 0x73, 0x74,
|
||||||
0x02,
|
0x02,
|
||||||
0x02, // Protocol version - Must be at least 0x02
|
0x02, // Protocol version - Must be at least 0x02
|
||||||
0x01
|
0x01
|
||||||
};
|
];
|
||||||
|
|
||||||
Serial.SendCommand(Command, new byte[] { 0x02 });
|
Serial.SendCommand(Command, [0x02]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetSecurityMode(byte Mode)
|
public void SetSecurityMode(byte Mode)
|
||||||
{
|
{
|
||||||
byte[] Command = new byte[2];
|
byte[] Command = [0x17, Mode];
|
||||||
Command[0] = 0x17;
|
|
||||||
Command[1] = Mode;
|
|
||||||
|
|
||||||
Serial.SendCommand(Command, new byte[] { 0x18 });
|
Serial.SendCommand(Command, [0x18]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use PartitionID 0x21
|
// Use PartitionID 0x21
|
||||||
public void OpenPartition(byte PartitionID)
|
public void OpenPartition(byte PartitionID)
|
||||||
{
|
{
|
||||||
byte[] Command = new byte[2];
|
byte[] Command = [0x1B, PartitionID];
|
||||||
Command[0] = 0x1B;
|
|
||||||
Command[1] = PartitionID;
|
|
||||||
|
|
||||||
Serial.SendCommand(Command, new byte[] { 0x1C });
|
Serial.SendCommand(Command, [0x1C]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ClosePartition()
|
public void ClosePartition()
|
||||||
{
|
{
|
||||||
Serial.SendCommand(new byte[] { 0x15 }, new byte[] { 0x16 });
|
Serial.SendCommand([0x15], [0x16]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Flash(UInt32 StartInBytes, Stream Data, UInt32 LengthInBytes = UInt32.MaxValue)
|
public void Flash(UInt32 StartInBytes, Stream Data, UInt32 LengthInBytes = UInt32.MaxValue)
|
||||||
@@ -222,7 +218,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
public void Reboot()
|
public void Reboot()
|
||||||
{
|
{
|
||||||
Serial.SendCommand(new byte[] { 0x0B }, new byte[] { 0x0C });
|
Serial.SendCommand([0x0B], [0x0C]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -33,8 +33,7 @@ namespace WPinternals
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IEnumerable<string> FilePaths = Directory.EnumerateFiles(Path);
|
foreach (string FilePath in Directory.EnumerateFiles(Path))
|
||||||
foreach (string FilePath in FilePaths)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -52,15 +52,15 @@ namespace WPinternals
|
|||||||
internal QualcommPartition(byte[] Binary, uint Offset = 0)
|
internal QualcommPartition(byte[] Binary, uint Offset = 0)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
System.Diagnostics.Debug.Print("Loader: " + Converter.ConvertHexToString(new SHA256Managed().ComputeHash(Binary, 0, Binary.Length), ""));
|
System.Diagnostics.Debug.Print("Loader: " + Converter.ConvertHexToString(SHA256.HashData(Binary.AsSpan(0, Binary.Length)), ""));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
this.Binary = Binary;
|
this.Binary = Binary;
|
||||||
|
|
||||||
byte[] LongHeaderPattern = new byte[] { 0xD1, 0xDC, 0x4B, 0x84, 0x34, 0x10, 0xD7, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
byte[] LongHeaderPattern = [0xD1, 0xDC, 0x4B, 0x84, 0x34, 0x10, 0xD7, 0x73, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||||
byte[] LongHeaderMask = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
byte[] LongHeaderMask = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00];
|
||||||
|
|
||||||
if (ByteOperations.FindPattern(Binary, Offset, 4, new byte[] { 0x7F, 0x45, 0x4C, 0x46 }, new byte[] { 0x00, 0x00, 0x00, 0x00 }, null) == 0)
|
if (ByteOperations.FindPattern(Binary, Offset, 4, [0x7F, 0x45, 0x4C, 0x46], [0x00, 0x00, 0x00, 0x00], null) == 0)
|
||||||
{
|
{
|
||||||
// This is an ELF image
|
// This is an ELF image
|
||||||
// First program header is a reference to the elf-header
|
// First program header is a reference to the elf-header
|
||||||
@@ -105,6 +105,8 @@ namespace WPinternals
|
|||||||
HeaderOffset = ImageOffset + (uint)LongHeaderPattern.Length;
|
HeaderOffset = ImageOffset + (uint)LongHeaderPattern.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint Version = ByteOperations.ReadUInt32(Binary, ImageOffset + 0X04);
|
||||||
|
|
||||||
if (ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00) != 0)
|
if (ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00) != 0)
|
||||||
{
|
{
|
||||||
ImageOffset = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00);
|
ImageOffset = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X00);
|
||||||
@@ -123,10 +125,31 @@ namespace WPinternals
|
|||||||
CodeSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X0C);
|
CodeSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X0C);
|
||||||
SignatureAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X10);
|
SignatureAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X10);
|
||||||
SignatureSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X14);
|
SignatureSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X14);
|
||||||
SignatureOffset = SignatureAddress - ImageAddress + ImageOffset;
|
|
||||||
CertificatesAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X18);
|
CertificatesAddress = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X18);
|
||||||
CertificatesSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X1C);
|
CertificatesSize = ByteOperations.ReadUInt32(Binary, HeaderOffset + 0X1C);
|
||||||
CertificatesOffset = CertificatesAddress - ImageAddress + ImageOffset;
|
|
||||||
|
if (SignatureAddress == 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
SignatureAddress = ImageAddress + CodeSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CertificatesAddress == 0xFFFFFFFF)
|
||||||
|
{
|
||||||
|
CertificatesAddress = SignatureAddress + SignatureSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Headers newer than version 5 need more padding here
|
||||||
|
if (Version > 5)
|
||||||
|
{
|
||||||
|
ImageOffset += 0x80;
|
||||||
|
}
|
||||||
|
|
||||||
|
SignatureOffset = ImageOffset + CodeSize;
|
||||||
|
CertificatesOffset = ImageOffset + CodeSize + SignatureSize;
|
||||||
|
|
||||||
|
// Keeping just in case
|
||||||
|
// SignatureOffset = SignatureAddress - ImageAddress + ImageOffset;
|
||||||
|
// CertificatesOffset = ImageSize - CertificatesSize + ImageOffset;
|
||||||
|
|
||||||
uint CurrentCertificateOffset = CertificatesOffset;
|
uint CurrentCertificateOffset = CertificatesOffset;
|
||||||
uint CertificateSize = 0;
|
uint CertificateSize = 0;
|
||||||
@@ -139,7 +162,7 @@ namespace WPinternals
|
|||||||
if ((CurrentCertificateOffset + CertificateSize) == (CertificatesOffset + CertificatesSize))
|
if ((CurrentCertificateOffset + CertificateSize) == (CertificatesOffset + CertificatesSize))
|
||||||
{
|
{
|
||||||
// This is the last certificate. So this is the root key.
|
// This is the last certificate. So this is the root key.
|
||||||
RootKeyHash = new SHA256Managed().ComputeHash(Binary, (int)CurrentCertificateOffset, (int)CertificateSize);
|
RootKeyHash = SHA256.HashData(Binary.AsSpan((int)CurrentCertificateOffset, (int)CertificateSize));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, ""));
|
System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, ""));
|
||||||
@@ -148,7 +171,7 @@ namespace WPinternals
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.Print("Cert: " + Converter.ConvertHexToString(new SHA256Managed().ComputeHash(Binary, (int)CurrentCertificateOffset, (int)CertificateSize), ""));
|
System.Diagnostics.Debug.Print("Cert: " + Converter.ConvertHexToString(SHA256.HashData(Binary.AsSpan((int)CurrentCertificateOffset, (int)CertificateSize)), ""));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
CurrentCertificateOffset += CertificateSize;
|
CurrentCertificateOffset += CertificateSize;
|
||||||
@@ -160,7 +183,7 @@ namespace WPinternals
|
|||||||
CurrentCertificateOffset -= CertificateSize;
|
CurrentCertificateOffset -= CertificateSize;
|
||||||
|
|
||||||
// This is the last certificate. So this is the root key.
|
// This is the last certificate. So this is the root key.
|
||||||
RootKeyHash = new SHA256Managed().ComputeHash(Binary, (int)CurrentCertificateOffset, (int)CertificateSize);
|
RootKeyHash = SHA256.HashData(Binary.AsSpan((int)CurrentCertificateOffset, (int)CertificateSize));
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, ""));
|
System.Diagnostics.Debug.Print("RKH: " + Converter.ConvertHexToString(RootKeyHash, ""));
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// 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.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WPinternals
|
||||||
|
{
|
||||||
|
internal delegate void ReadyHandler();
|
||||||
|
|
||||||
|
internal class QualcommSahara
|
||||||
|
{
|
||||||
|
private readonly QualcommSerial Serial;
|
||||||
|
|
||||||
|
public QualcommSahara(QualcommSerial Serial)
|
||||||
|
{
|
||||||
|
Serial.EncodeCommands = false;
|
||||||
|
Serial.DecodeResponses = false;
|
||||||
|
this.Serial = Serial;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] BuildCommandPacket(QualcommSaharaCommand SaharaCommand, byte[] CommandBuffer = null)
|
||||||
|
{
|
||||||
|
UInt32 CommandID = (uint)SaharaCommand;
|
||||||
|
UInt32 CommandBufferLength = 0;
|
||||||
|
if (CommandBuffer != null)
|
||||||
|
{
|
||||||
|
CommandBufferLength = (UInt32)CommandBuffer.Length;
|
||||||
|
}
|
||||||
|
UInt32 Length = 0x8u + CommandBufferLength;
|
||||||
|
|
||||||
|
byte[] Packet = new byte[Length];
|
||||||
|
ByteOperations.WriteUInt32(Packet, 0x00, CommandID);
|
||||||
|
ByteOperations.WriteUInt32(Packet, 0x04, Length);
|
||||||
|
|
||||||
|
if (CommandBuffer != null && CommandBufferLength != 0)
|
||||||
|
{
|
||||||
|
Buffer.BlockCopy(CommandBuffer, 0, Packet, 0x08, CommandBuffer.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Packet;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] BuildHelloResponsePacket(QualcommSaharaMode SaharaMode, UInt32 ProtocolVersion = 2, UInt32 SupportedVersion = 1, UInt32 MaxPacketLength = 0 /* 0: Status OK */)
|
||||||
|
{
|
||||||
|
UInt32 Mode = (uint)SaharaMode;
|
||||||
|
|
||||||
|
// Hello packet:
|
||||||
|
// xxxxxxxx = Protocol version
|
||||||
|
// xxxxxxxx = Supported version
|
||||||
|
// xxxxxxxx = Max packet length
|
||||||
|
// xxxxxxxx = Expected mode
|
||||||
|
// 6 dwords reserved space
|
||||||
|
byte[] Hello = new byte[0x28];
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x00, ProtocolVersion);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x04, SupportedVersion);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x08, MaxPacketLength);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x0C, Mode);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x10, 0);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x14, 0);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x18, 0);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x1C, 0);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x20, 0);
|
||||||
|
ByteOperations.WriteUInt32(Hello, 0x24, 0);
|
||||||
|
|
||||||
|
return BuildCommandPacket(QualcommSaharaCommand.HelloResponse, Hello);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] BuildExecuteRequestPacket(UInt32 RequestID)
|
||||||
|
{
|
||||||
|
byte[] Execute = new byte[0x04];
|
||||||
|
ByteOperations.WriteUInt32(Execute, 0x00, RequestID);
|
||||||
|
return BuildCommandPacket(QualcommSaharaCommand.ExecuteRequest, Execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] BuildExecuteDataPacket(UInt32 RequestID)
|
||||||
|
{
|
||||||
|
byte[] Execute = new byte[0x04];
|
||||||
|
ByteOperations.WriteUInt32(Execute, 0x00, RequestID);
|
||||||
|
return BuildCommandPacket(QualcommSaharaCommand.ExecuteData, Execute);
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[][] GetRKHs()
|
||||||
|
{
|
||||||
|
Serial.SendData(BuildExecuteRequestPacket(0x3));
|
||||||
|
|
||||||
|
byte[] ReadDataRequest = Serial.GetResponse(null);
|
||||||
|
UInt32 ResponseID = ByteOperations.ReadUInt32(ReadDataRequest, 0);
|
||||||
|
|
||||||
|
if (ResponseID != 0xE)
|
||||||
|
{
|
||||||
|
throw new BadConnectionException();
|
||||||
|
}
|
||||||
|
|
||||||
|
uint RKHLength = ByteOperations.ReadUInt32(ReadDataRequest, 0x0C);
|
||||||
|
|
||||||
|
Serial.SendData(BuildExecuteDataPacket(0x3));
|
||||||
|
|
||||||
|
byte[] Response = Serial.GetResponse(null, Length: (int)RKHLength);
|
||||||
|
|
||||||
|
List<byte[]> RootKeyHashes = new();
|
||||||
|
for (int i = 0; i < RKHLength / 0x20; i++)
|
||||||
|
{
|
||||||
|
RootKeyHashes.Add(Response[(i * 0x20)..((i + 1) * 0x20)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return [.. RootKeyHashes];
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] GetRKH()
|
||||||
|
{
|
||||||
|
int Step = 0;
|
||||||
|
UInt32 Offset = 0;
|
||||||
|
UInt32 Length = 0;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Step = 1;
|
||||||
|
byte[] Hello = Serial.GetResponse([0x01, 0x00, 0x00, 0x00]);
|
||||||
|
|
||||||
|
// Incoming Hello packet:
|
||||||
|
// 00000001 = Hello command id
|
||||||
|
// xxxxxxxx = Length
|
||||||
|
// xxxxxxxx = Protocol version
|
||||||
|
// xxxxxxxx = Supported version
|
||||||
|
// xxxxxxxx = Max packet length
|
||||||
|
// xxxxxxxx = Expected mode
|
||||||
|
// 6 dwords reserved space
|
||||||
|
LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly);
|
||||||
|
|
||||||
|
Step = 2;
|
||||||
|
byte[] HelloResponse = BuildHelloResponsePacket(QualcommSaharaMode.Command);
|
||||||
|
Serial.SendData(HelloResponse);
|
||||||
|
|
||||||
|
Step = 3;
|
||||||
|
byte[] ReadDataRequest = Serial.GetResponse(null);
|
||||||
|
UInt32 ResponseID = ByteOperations.ReadUInt32(ReadDataRequest, 0);
|
||||||
|
|
||||||
|
if (ResponseID != 0xB)
|
||||||
|
{
|
||||||
|
throw new BadConnectionException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Step = 4;
|
||||||
|
byte[][] RKHs = GetRKHs();
|
||||||
|
return RKHs[0];
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
LogFile.LogException(Ex, LogType.FileAndConsole, Step.ToString() + " 0x" + Offset.ToString("X8") + " 0x" + Length.ToString("X8"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SendImage(string Path)
|
||||||
|
{
|
||||||
|
bool Result = true;
|
||||||
|
|
||||||
|
LogFile.Log("Sending programmer: " + Path, LogType.FileOnly);
|
||||||
|
|
||||||
|
int Step = 0;
|
||||||
|
UInt32 Offset = 0;
|
||||||
|
UInt32 Length = 0;
|
||||||
|
|
||||||
|
byte[] ImageBuffer = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Step = 1;
|
||||||
|
byte[] Hello = Serial.GetResponse([0x01, 0x00, 0x00, 0x00]);
|
||||||
|
|
||||||
|
// Incoming Hello packet:
|
||||||
|
// 00000001 = Hello command id
|
||||||
|
// xxxxxxxx = Length
|
||||||
|
// xxxxxxxx = Protocol version
|
||||||
|
// xxxxxxxx = Supported version
|
||||||
|
// xxxxxxxx = Max packet length
|
||||||
|
// xxxxxxxx = Expected mode
|
||||||
|
// 6 dwords reserved space
|
||||||
|
LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly);
|
||||||
|
|
||||||
|
Step = 2;
|
||||||
|
byte[] HelloResponse = BuildHelloResponsePacket(QualcommSaharaMode.ImageTransferPending);
|
||||||
|
Serial.SendData(HelloResponse);
|
||||||
|
|
||||||
|
Step = 3;
|
||||||
|
using FileStream FileStream = new(Path, FileMode.Open, FileAccess.Read);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
Step = 4;
|
||||||
|
byte[] ReadDataRequest = Serial.GetResponse(null);
|
||||||
|
UInt32 ResponseID = ByteOperations.ReadUInt32(ReadDataRequest, 0);
|
||||||
|
if (ResponseID == 4)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ResponseID != 3)
|
||||||
|
{
|
||||||
|
Step = 5;
|
||||||
|
throw new BadConnectionException();
|
||||||
|
}
|
||||||
|
|
||||||
|
Offset = ByteOperations.ReadUInt32(ReadDataRequest, 0x0C);
|
||||||
|
Length = ByteOperations.ReadUInt32(ReadDataRequest, 0x10);
|
||||||
|
if ((ImageBuffer == null) || (ImageBuffer.Length != Length))
|
||||||
|
{
|
||||||
|
ImageBuffer = new byte[Length];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (FileStream.Position != Offset)
|
||||||
|
{
|
||||||
|
FileStream.Seek(Offset, SeekOrigin.Begin);
|
||||||
|
}
|
||||||
|
|
||||||
|
Step = 6;
|
||||||
|
FileStream.Read(ImageBuffer, 0, (int)Length);
|
||||||
|
|
||||||
|
Step = 7;
|
||||||
|
Serial.SendData(ImageBuffer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception Ex)
|
||||||
|
{
|
||||||
|
LogFile.LogException(Ex, LogType.FileAndConsole, Step.ToString() + " 0x" + Offset.ToString("X8") + " 0x" + Length.ToString("X8"));
|
||||||
|
Result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Result)
|
||||||
|
{
|
||||||
|
LogFile.Log("Programmer loaded into phone memory", LogType.FileOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Handshake()
|
||||||
|
{
|
||||||
|
bool Result = true;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] Hello = Serial.GetResponse([0x01, 0x00, 0x00, 0x00]);
|
||||||
|
|
||||||
|
// Incoming Hello packet:
|
||||||
|
// 00000001 = Hello command id
|
||||||
|
// xxxxxxxx = Length
|
||||||
|
// xxxxxxxx = Protocol version
|
||||||
|
// xxxxxxxx = Supported version
|
||||||
|
// xxxxxxxx = Max packet length
|
||||||
|
// xxxxxxxx = Expected mode
|
||||||
|
// 6 dwords reserved space
|
||||||
|
LogFile.Log("Protocol: 0x" + ByteOperations.ReadUInt32(Hello, 0x08).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Supported: 0x" + ByteOperations.ReadUInt32(Hello, 0x0C).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("MaxLength: 0x" + ByteOperations.ReadUInt32(Hello, 0x10).ToString("X8"), LogType.FileOnly);
|
||||||
|
LogFile.Log("Mode: 0x" + ByteOperations.ReadUInt32(Hello, 0x14).ToString("X8"), LogType.FileOnly);
|
||||||
|
|
||||||
|
byte[] HelloResponse = BuildHelloResponsePacket(QualcommSaharaMode.ImageTransferPending);
|
||||||
|
|
||||||
|
byte[] Ready = Serial.SendCommand(HelloResponse, [0x03, 0x00, 0x00, 0x00]);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Result = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetSahara()
|
||||||
|
{
|
||||||
|
Serial.SendCommand(BuildCommandPacket(QualcommSaharaCommand.ResetRequest), [0x08, 0x00, 0x00, 0x00]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SwitchMode(QualcommSaharaMode Mode)
|
||||||
|
{
|
||||||
|
byte[] SwitchMode = new byte[0x04];
|
||||||
|
ByteOperations.WriteUInt32(SwitchMode, 0x00, (UInt32)Mode);
|
||||||
|
byte[] SwitchModeCommand = BuildCommandPacket(QualcommSaharaCommand.SwitchMode, SwitchMode);
|
||||||
|
|
||||||
|
byte[] ResponsePattern = null;
|
||||||
|
switch (Mode)
|
||||||
|
{
|
||||||
|
case QualcommSaharaMode.ImageTransferPending:
|
||||||
|
ResponsePattern = [0x04, 0x00, 0x00, 0x00];
|
||||||
|
break;
|
||||||
|
case QualcommSaharaMode.MemoryDebug:
|
||||||
|
ResponsePattern = [0x09, 0x00, 0x00, 0x00];
|
||||||
|
break;
|
||||||
|
case QualcommSaharaMode.Command:
|
||||||
|
ResponsePattern = [0x0B, 0x00, 0x00, 0x00];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Serial.SendCommand(SwitchModeCommand, ResponsePattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void StartProgrammer()
|
||||||
|
{
|
||||||
|
LogFile.Log("Starting programmer", LogType.FileAndConsole);
|
||||||
|
byte[] DoneCommand = BuildCommandPacket(QualcommSaharaCommand.DoneRequest);
|
||||||
|
bool Started = false;
|
||||||
|
int count = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] DoneResponse = Serial.SendCommand(DoneCommand, [0x06, 0x00, 0x00, 0x00]);
|
||||||
|
Started = true;
|
||||||
|
}
|
||||||
|
catch (BadConnectionException)
|
||||||
|
{
|
||||||
|
LogFile.Log("Problem while starting programmer. Attempting again.", LogType.FileAndConsole);
|
||||||
|
}
|
||||||
|
} while (!Started && count < 3);
|
||||||
|
if (count >= 3 && !Started)
|
||||||
|
{
|
||||||
|
LogFile.Log("Maximum number of attempts to start the programmer exceeded.", LogType.FileAndConsole);
|
||||||
|
throw new BadConnectionException();
|
||||||
|
}
|
||||||
|
LogFile.Log("Programmer being launched on phone", LogType.FileOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> LoadProgrammer(string ProgrammerPath)
|
||||||
|
{
|
||||||
|
bool SendImageResult = await Task.Run(() => SendImage(ProgrammerPath));
|
||||||
|
if (!SendImageResult)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Run(() => StartProgrammer());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
namespace WPinternals
|
||||||
|
{
|
||||||
|
internal enum QualcommSaharaCommand : uint
|
||||||
|
{
|
||||||
|
HelloRequest = 0x01,
|
||||||
|
HelloResponse = 0x02,
|
||||||
|
ReadData = 0x03,
|
||||||
|
EndTransfer = 0x04,
|
||||||
|
DoneRequest = 0x05,
|
||||||
|
DoneResponse = 0x06,
|
||||||
|
ResetRequest = 0x07,
|
||||||
|
ResetResponse = 0x08,
|
||||||
|
MemoryDebug = 0x09,
|
||||||
|
MemoryRead = 0x0A,
|
||||||
|
CommandReady = 0x0B,
|
||||||
|
SwitchMode = 0x0C,
|
||||||
|
ExecuteRequest = 0x0D,
|
||||||
|
ExecuteResponse = 0x0E,
|
||||||
|
ExecuteData = 0x0F,
|
||||||
|
MemoryDebug64 = 0x10,
|
||||||
|
MemoryRead64 = 0x11,
|
||||||
|
MemoryReadData64 = 0x12,
|
||||||
|
ResetStateMachineIdentifier = 0x13
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
|
// to deal in the Software without restriction, including without limitation
|
||||||
|
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
// and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
// Software is furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
// DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
namespace WPinternals
|
||||||
|
{
|
||||||
|
internal enum QualcommSaharaMode : uint
|
||||||
|
{
|
||||||
|
ImageTransferPending = 0x00,
|
||||||
|
ImagetransferComplete = 0x01,
|
||||||
|
MemoryDebug = 0x02,
|
||||||
|
Command = 0x03
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -38,7 +38,7 @@ namespace WPinternals
|
|||||||
{
|
{
|
||||||
CRC16 = new CRC16(0x1189, 0xFFFF, 0xFFFF);
|
CRC16 = new CRC16(0x1189, 0xFFFF, 0xFFFF);
|
||||||
|
|
||||||
string[] DevicePathElements = DevicePath.Split(new char[] { '#' });
|
string[] DevicePathElements = DevicePath.Split(['#']);
|
||||||
if (string.Equals(DevicePathElements[3], "{86E0D1E0-8089-11D0-9CE4-08003E301F73}", StringComparison.CurrentCultureIgnoreCase))
|
if (string.Equals(DevicePathElements[3], "{86E0D1E0-8089-11D0-9CE4-08003E301F73}", StringComparison.CurrentCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
string PortName = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\" + DevicePathElements[1] + @"\" + DevicePathElements[2] + @"\Device Parameters", "PortName", null);
|
string PortName = (string)Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\" + DevicePathElements[1] + @"\" + DevicePathElements[2] + @"\Device Parameters", "PortName", null);
|
||||||
@@ -84,10 +84,10 @@ namespace WPinternals
|
|||||||
return GetResponse(ResponsePattern);
|
return GetResponse(ResponsePattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal byte[] GetResponse(byte[] ResponsePattern)
|
internal byte[] GetResponse(byte[] ResponsePattern, int Length = 0x2000)
|
||||||
{
|
{
|
||||||
byte[] ResponseBuffer = new byte[0x2000];
|
byte[] ResponseBuffer = new byte[Length];
|
||||||
int Length = 0;
|
Length = 0;
|
||||||
bool IsIncomplete = false;
|
bool IsIncomplete = false;
|
||||||
|
|
||||||
do
|
do
|
||||||
@@ -323,7 +323,7 @@ namespace WPinternals
|
|||||||
public class CRC16
|
public class CRC16
|
||||||
{
|
{
|
||||||
private readonly UInt16[] ChecksumTable =
|
private readonly UInt16[] ChecksumTable =
|
||||||
new UInt16[] {
|
[
|
||||||
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
|
||||||
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
|
||||||
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
|
||||||
@@ -356,7 +356,7 @@ namespace WPinternals
|
|||||||
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
|
||||||
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
|
||||||
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
|
||||||
};
|
];
|
||||||
|
|
||||||
private readonly UInt16 Seed, FinalXor;
|
private readonly UInt16 Seed, FinalXor;
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -29,11 +29,11 @@ namespace WPinternals
|
|||||||
internal byte[] GenerateExtraSector(byte[] PartitionHeader)
|
internal byte[] GenerateExtraSector(byte[] PartitionHeader)
|
||||||
{
|
{
|
||||||
UInt32? Offset = ByteOperations.FindPattern(Binary,
|
UInt32? Offset = ByteOperations.FindPattern(Binary,
|
||||||
new byte[] {
|
[
|
||||||
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
}, null, null);
|
], null, null);
|
||||||
if (Offset == null)
|
if (Offset == null)
|
||||||
{
|
{
|
||||||
throw new BadImageFormatException();
|
throw new BadImageFormatException();
|
||||||
@@ -43,12 +43,12 @@ namespace WPinternals
|
|||||||
|
|
||||||
byte[] FoundPattern = new byte[0x10];
|
byte[] FoundPattern = new byte[0x10];
|
||||||
Offset = ByteOperations.FindPattern(Binary,
|
Offset = ByteOperations.FindPattern(Binary,
|
||||||
new byte[] {
|
[
|
||||||
0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF
|
0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1, 0xFF, 0xFF, 0xFF, 0xFF
|
||||||
},
|
],
|
||||||
new byte[] {
|
[
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF
|
||||||
},
|
],
|
||||||
FoundPattern);
|
FoundPattern);
|
||||||
if (Offset == null)
|
if (Offset == null)
|
||||||
{
|
{
|
||||||
@@ -59,14 +59,14 @@ namespace WPinternals
|
|||||||
UInt32 GlobalIsSecurityEnabledAddress = SharedMemoryAddress + 0x28;
|
UInt32 GlobalIsSecurityEnabledAddress = SharedMemoryAddress + 0x28;
|
||||||
|
|
||||||
Offset = ByteOperations.FindPattern(Binary,
|
Offset = ByteOperations.FindPattern(Binary,
|
||||||
new byte[] {
|
[
|
||||||
0x01, 0xFF, 0xA0, 0xE3, 0xFF, 0xFF, 0xA0, 0xE1, 0x1C, 0xD0, 0x8D, 0xE2, 0xF0, 0x4F, 0xBD, 0xE8,
|
0x01, 0xFF, 0xA0, 0xE3, 0xFF, 0xFF, 0xA0, 0xE1, 0x1C, 0xD0, 0x8D, 0xE2, 0xF0, 0x4F, 0xBD, 0xE8,
|
||||||
0x1E, 0xFF, 0x2F, 0xE1
|
0x1E, 0xFF, 0x2F, 0xE1
|
||||||
},
|
],
|
||||||
new byte[] {
|
[
|
||||||
0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00
|
0x00, 0x00, 0x00, 0x00
|
||||||
},
|
],
|
||||||
null);
|
null);
|
||||||
if (Offset == null)
|
if (Offset == null)
|
||||||
{
|
{
|
||||||
@@ -78,7 +78,7 @@ namespace WPinternals
|
|||||||
byte[] Sector = new byte[0x200];
|
byte[] Sector = new byte[0x200];
|
||||||
Array.Clear(Sector, 0, 0x200);
|
Array.Clear(Sector, 0, 0x200);
|
||||||
|
|
||||||
byte[] Content = new byte[] {
|
byte[] Content = [
|
||||||
0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0xBD, 0x02, 0x00,
|
0x16, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x28, 0xBD, 0x02, 0x00,
|
||||||
0xD8, 0x01, 0x00, 0x00, 0xD8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0xD8, 0x01, 0x00, 0x00, 0xD8, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xE3, 0x3C, 0x10, 0x9F, 0xE5,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA0, 0xE3, 0x3C, 0x10, 0x9F, 0xE5,
|
||||||
@@ -88,11 +88,11 @@ namespace WPinternals
|
|||||||
0x04, 0x10, 0x81, 0xE2, 0x03, 0x00, 0x50, 0xE1, 0xF9, 0xFF, 0xFF, 0xBA, 0x14, 0xF0, 0x9F, 0xE5,
|
0x04, 0x10, 0x81, 0xE2, 0x03, 0x00, 0x50, 0xE1, 0xF9, 0xFF, 0xFF, 0xBA, 0x14, 0xF0, 0x9F, 0xE5,
|
||||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x90, 0xBF, 0x02, 0x00, 0xD0, 0xBF, 0x02, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x02, 0x00, 0x90, 0xBF, 0x02, 0x00, 0xD0, 0xBF, 0x02, 0x00,
|
||||||
0xA0, 0xBD, 0x02, 0x00, 0xA0, 0xBE, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
|
0xA0, 0xBD, 0x02, 0x00, 0xA0, 0xBE, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
};
|
];
|
||||||
|
|
||||||
byte[] PartitionTypeGuid = new byte[] {
|
byte[] PartitionTypeGuid = [
|
||||||
0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74
|
0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74, 0x74
|
||||||
};
|
];
|
||||||
|
|
||||||
Buffer.BlockCopy(Content, 0, Sector, 0, Content.Length);
|
Buffer.BlockCopy(Content, 0, Sector, 0, Content.Length);
|
||||||
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -35,12 +35,12 @@ namespace WPinternals
|
|||||||
internal byte[] Patch()
|
internal byte[] Patch()
|
||||||
{
|
{
|
||||||
UInt32? PatchOffset = ByteOperations.FindPattern(Binary,
|
UInt32? PatchOffset = ByteOperations.FindPattern(Binary,
|
||||||
new byte[] {
|
[
|
||||||
0xFF, 0xFF, 0xFF, 0xE3, 0x01, 0x0E, 0x42, 0xE3, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1
|
0xFF, 0xFF, 0xFF, 0xE3, 0x01, 0x0E, 0x42, 0xE3, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1
|
||||||
},
|
],
|
||||||
new byte[] {
|
[
|
||||||
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||||
},
|
],
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (PatchOffset == null)
|
if (PatchOffset == null)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -50,8 +50,8 @@ namespace WPinternals
|
|||||||
// If not succeeded, then try to parse it as raw image
|
// If not succeeded, then try to parse it as raw image
|
||||||
if (Binary == null)
|
if (Binary == null)
|
||||||
{
|
{
|
||||||
byte[] SBL3Pattern = new byte[] { 0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF };
|
byte[] SBL3Pattern = [0x18, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x8F, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||||
byte[] SBL3Mask = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF };
|
byte[] SBL3Mask = [0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF];
|
||||||
|
|
||||||
UInt32? Offset = ByteOperations.FindPatternInFile(FileName, SBL3Pattern, SBL3Mask, out byte[] SBL3Header);
|
UInt32? Offset = ByteOperations.FindPatternInFile(FileName, SBL3Pattern, SBL3Mask, out byte[] SBL3Header);
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ namespace WPinternals
|
|||||||
internal byte[] Patch()
|
internal byte[] Patch()
|
||||||
{
|
{
|
||||||
UInt32? PatchOffset = ByteOperations.FindPattern(Binary,
|
UInt32? PatchOffset = ByteOperations.FindPattern(Binary,
|
||||||
new byte[] { 0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1 },
|
[0x04, 0x00, 0x9F, 0xE5, 0x28, 0x00, 0xD0, 0xE5, 0x1E, 0xFF, 0x2F, 0xE1],
|
||||||
null, null);
|
null, null);
|
||||||
|
|
||||||
if (PatchOffset == null)
|
if (PatchOffset == null)
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -256,7 +256,7 @@ namespace WPinternals
|
|||||||
// but the sections that are used in Windows Phone EFI's all have a header of 4 bytes.
|
// but the sections that are used in Windows Phone EFI's all have a header of 4 bytes.
|
||||||
if (SectionType == 0x15)
|
if (SectionType == 0x15)
|
||||||
{
|
{
|
||||||
CurrentEFI.Name = ByteOperations.ReadUnicodeString(DecompressedImage, DecompressedSectionHeaderOffset + 0x04, SectionSize - 0x04).TrimEnd(new char[] { (char)0, ' ' });
|
CurrentEFI.Name = ByteOperations.ReadUnicodeString(DecompressedImage, DecompressedSectionHeaderOffset + 0x04, SectionSize - 0x04).TrimEnd([(char)0, ' ']);
|
||||||
}
|
}
|
||||||
else if ((SectionType == 0x10) || (SectionType == 0x19))
|
else if ((SectionType == 0x10) || (SectionType == 0x19))
|
||||||
{
|
{
|
||||||
@@ -599,8 +599,8 @@ namespace WPinternals
|
|||||||
ClearEfiChecksum(SecurityDxe);
|
ClearEfiChecksum(SecurityDxe);
|
||||||
|
|
||||||
UInt32? PatchOffset = ByteOperations.FindPattern(SecurityDxe,
|
UInt32? PatchOffset = ByteOperations.FindPattern(SecurityDxe,
|
||||||
new byte[] { 0xF0, 0x41, 0x2D, 0xE9, 0xFF, 0xFF, 0xB0, 0xE1, 0x28, 0xD0, 0x4D, 0xE2, 0xFF, 0xFF, 0xA0, 0xE1, 0x00, 0x00, 0xFF, 0x13, 0x20, 0xFF, 0xA0, 0xE3 },
|
[0xF0, 0x41, 0x2D, 0xE9, 0xFF, 0xFF, 0xB0, 0xE1, 0x28, 0xD0, 0x4D, 0xE2, 0xFF, 0xFF, 0xA0, 0xE1, 0x00, 0x00, 0xFF, 0x13, 0x20, 0xFF, 0xA0, 0xE3],
|
||||||
new byte[] { 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00 },
|
[0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00],
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (PatchOffset == null)
|
if (PatchOffset == null)
|
||||||
@@ -616,8 +616,8 @@ namespace WPinternals
|
|||||||
ClearEfiChecksum(SecurityServicesDxe);
|
ClearEfiChecksum(SecurityServicesDxe);
|
||||||
|
|
||||||
PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe,
|
PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe,
|
||||||
new byte[] { 0x10, 0xFF, 0xFF, 0xE5, 0x80, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A },
|
[0x10, 0xFF, 0xFF, 0xE5, 0x80, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A],
|
||||||
new byte[] { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00 },
|
[0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00],
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (PatchOffset == null)
|
if (PatchOffset == null)
|
||||||
@@ -628,8 +628,8 @@ namespace WPinternals
|
|||||||
ByteOperations.WriteUInt8(SecurityServicesDxe, (UInt32)PatchOffset + 0x0B, 0xEA);
|
ByteOperations.WriteUInt8(SecurityServicesDxe, (UInt32)PatchOffset + 0x0B, 0xEA);
|
||||||
|
|
||||||
PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe,
|
PatchOffset = ByteOperations.FindPattern(SecurityServicesDxe,
|
||||||
new byte[] { 0x11, 0xFF, 0xFF, 0xE5, 0x40, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A },
|
[0x11, 0xFF, 0xFF, 0xE5, 0x40, 0xFF, 0x10, 0xE3, 0xFF, 0xFF, 0xFF, 0x0A],
|
||||||
new byte[] { 0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00 },
|
[0x00, 0xFF, 0xFF, 0x00, 0x00, 0xFF, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0x00],
|
||||||
null);
|
null);
|
||||||
|
|
||||||
if (PatchOffset == null)
|
if (PatchOffset == null)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
Copyright(c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
Copyright(c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
copy of this software and associated documentation files(the "Software"),
|
copy of this software and associated documentation files(the "Software"),
|
||||||
|
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 50 KiB |
@@ -10,7 +10,7 @@ using System.Windows;
|
|||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("")]
|
[assembly: AssemblyCompany("")]
|
||||||
[assembly: AssemblyProduct("WPinternals")]
|
[assembly: AssemblyProduct("WPinternals")]
|
||||||
[assembly: AssemblyCopyright("Copyright © 2018-2019")]
|
[assembly: AssemblyCopyright("Copyright © 2018-2023")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: AssemblyCulture("")]
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
@@ -47,5 +47,5 @@ using System.Windows;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("2.9.*")]
|
[assembly: AssemblyVersion("3.0.*")]
|
||||||
// [assembly: AssemblyFileVersion("1.0.0.0")]
|
// [assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -272,8 +272,9 @@ namespace WPinternals
|
|||||||
// Send and start programmer
|
// Send and start programmer
|
||||||
QualcommSerial Serial = (QualcommSerial)Notifier.CurrentModel;
|
QualcommSerial Serial = (QualcommSerial)Notifier.CurrentModel;
|
||||||
QualcommSahara Sahara = new(Serial);
|
QualcommSahara Sahara = new(Serial);
|
||||||
|
QualcommFirehose Firehose = new(Serial);
|
||||||
|
|
||||||
if (await Sahara.Reset(ProgrammerPath))
|
if (await Sahara.LoadProgrammer(ProgrammerPath) && await Firehose.Reset())
|
||||||
{
|
{
|
||||||
LogFile.Log("Emergency programmer test succeeded", LogType.FileAndConsole);
|
LogFile.Log("Emergency programmer test succeeded", LogType.FileAndConsole);
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||
@@ -39,5 +39,21 @@ namespace WPinternals
|
|||||||
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor;
|
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Minor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int BuildVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int RevisionVersion
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Revision;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2018, Rene Lergner - wpinternals.net - @Heathcliff74xda
|
// Copyright (c) 2018, Rene Lergner - @Heathcliff74xda
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining a
|
// Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
// copy of this software and associated documentation files (the "Software"),
|
// copy of this software and associated documentation files (the "Software"),
|
||||||