Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit 3599a51

Browse files
committed
Feature update, disk backups and ffu conversion
Added: - FFU Conversion, limited to wp8 ffu format - whole disk and seperate partition backup
1 parent d38214c commit 3599a51

16 files changed

Lines changed: 2960 additions & 51 deletions

4.png

64.8 KB
Loading

README.md

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,18 @@
22

33
A desktop tool to help with various task and configurations with Windows Phones
44

5-
![](1.png)
6-
![](2.png)
7-
![](3.png)
5+
![](1.png | width=50)
6+
![](2.png | width=50)
7+
![](3.png | width=50)
8+
![](4.png | width=50)
89

910

1011
### Updated:
1112
Added:
12-
- Modify Page File size
13-
- Failsafe for if the reg file is already mounted (in case the app crashes while hives mounted)
14-
- Debug messages
15-
- Device Portal on/off and Auth
16-
- Developer Mode config
17-
- Windows Firewall Config
18-
- Fixes to reading Reg Keys to avoid null returns
19-
- Windows Update settings
20-
- Flight Signing enabler
13+
- Backup your Phone's whole disk and/or MainOS,Data and EFIESP
14+
- Convert WP8 FFU files to `.vhdx` (W10M FFUs not currently supported)
15+
16+
(NOTE: Disk reading is slow on my tests, I plan to look at improving this. Also there way be a few bugs, this is my first time using disk management.)
2117

2218

2319
# What can it do?

Windows 10 Mobile Toolbox.sln

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.32126.315
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Windows 10 Mobile Toolbox", "Windows 10 Mobile Toolbox\Windows 10 Mobile Toolbox.csproj", "{DE89CF07-5C70-4BAC-BEFF-5F204561A800}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Debug|x64 = Debug|x64
12+
Debug|x86 = Debug|x86
13+
Release|Any CPU = Release|Any CPU
14+
Release|x64 = Release|x64
15+
Release|x86 = Release|x86
16+
EndGlobalSection
17+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
18+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
19+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|Any CPU.Build.0 = Debug|Any CPU
20+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|x64.ActiveCfg = Debug|x64
21+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|x64.Build.0 = Debug|x64
22+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|x86.ActiveCfg = Debug|x86
23+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Debug|x86.Build.0 = Debug|x86
24+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|Any CPU.ActiveCfg = Release|Any CPU
25+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|Any CPU.Build.0 = Release|Any CPU
26+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|x64.ActiveCfg = Release|x64
27+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|x64.Build.0 = Release|x64
28+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|x86.ActiveCfg = Release|x86
29+
{DE89CF07-5C70-4BAC-BEFF-5F204561A800}.Release|x86.Build.0 = Release|x86
30+
EndGlobalSection
31+
GlobalSection(SolutionProperties) = preSolution
32+
HideSolutionNode = FALSE
33+
EndGlobalSection
34+
GlobalSection(ExtensibilityGlobals) = postSolution
35+
SolutionGuid = {316B38F1-956D-4FA7-A052-4177606D8BCD}
36+
EndGlobalSection
37+
EndGlobal
347 KB
Binary file not shown.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Runtime.InteropServices;
7+
using System.IO;
8+
using System.Windows;
9+
10+
namespace DiskManager
11+
{
12+
public class DiskManager
13+
{
14+
//--------------------------------------------------------------------------------------------------------
15+
[DllImport("kernel32.dll")]
16+
private static extern int CreateFile(
17+
string lpFileName, int dwDesiredAccess,
18+
int dwShareMode, int lpSecurityAttributes,
19+
int dwCreationDisposition, int dwFlagsAndAttributes,
20+
int hTemplateFile);
21+
22+
[DllImport("kernel32.dll")]
23+
private static extern int CloseHandle(int hObject);
24+
25+
[DllImport("kernel32.dll")]
26+
private static extern int ReadFile(
27+
int hFile,
28+
byte[] lpBuffer,
29+
int nNumberOfBytesToRead,
30+
ref int lpNumberOfBytesRead,
31+
int lpOverlapped);
32+
33+
[DllImport("kernel32.dll")]
34+
private static extern int WriteFile(
35+
int hFile,
36+
byte[] lpBuffer,
37+
int nNumberOfBytesToWrite,
38+
ref int lpNumberOfBytesWritten,
39+
int lpOverlapped);
40+
41+
[DllImport("kernel32.dll")]
42+
private static extern int SetFilePointer(
43+
int hFile,
44+
int nDistanceToMove,
45+
ref int lpDistanceToMoveHigh,
46+
uint nMoveMethod);
47+
48+
const int BUFFERSIZE = 8335360;
49+
const int BYTES_PER_SECTOR = 4096;
50+
char diskLetter;
51+
int diskHandle;
52+
string filePath;
53+
54+
const int GENERIC_READ = unchecked((int)0x80000000);
55+
const int FILE_SHARE_READ = 1;
56+
const int FILE_SHARE_WRITE = 2;
57+
const int OPEN_EXISTING = 3;
58+
const Int64 INVALID_HANDLE_VALUE = -1;
59+
const int FILE_ATTRIBUTE_NORMAL = 0x80;
60+
const int FILE_BEGIN = 0;
61+
//--------------------------------------------------------------------------------------------------------
62+
63+
public byte [] readDisk(char diskLetter)
64+
{
65+
this.diskLetter = diskLetter;
66+
createDiskHandle();
67+
68+
int lpNumberOfBytesRead=0;
69+
byte [] buf = new byte[BUFFERSIZE];
70+
if (ReadFile(diskHandle, buf, BUFFERSIZE, ref lpNumberOfBytesRead, 0) == 0)
71+
{
72+
73+
/*TO DO:
74+
throw and handle exceptions
75+
Terminal failure: Unable to read from disk.
76+
*/
77+
CloseHandle(diskHandle);
78+
throw new Exception("ERROR MESSAGE");
79+
80+
}
81+
return buf;
82+
}
83+
84+
public void writeToDisk(byte [] sectorBuffer, int sectorNumber)
85+
{
86+
int nNumberOfBytesToWrite = BYTES_PER_SECTOR;
87+
int lpNumberOfBytesWritten = 0;
88+
int lpDistanceToMoveHigh = 0;
89+
90+
SetFilePointer(diskHandle, BYTES_PER_SECTOR * sectorNumber, ref lpDistanceToMoveHigh, FILE_BEGIN);
91+
92+
if (WriteFile(diskHandle, sectorBuffer, nNumberOfBytesToWrite, ref lpNumberOfBytesWritten, 0) == 0)
93+
{
94+
/*TO DO:
95+
throw and handle exceptions
96+
Terminal failure: Unable to write to disk.
97+
*/
98+
throw new Exception("ERROR MESSAGE");
99+
100+
}
101+
}
102+
103+
public void createImage(string filePath, byte [] buf)
104+
{
105+
this.filePath = filePath;
106+
FileInfo fileInfo = new FileInfo(filePath);
107+
bool exists = System.IO.Directory.Exists(fileInfo.Directory.ToString());
108+
109+
if (!exists)
110+
{
111+
System.IO.Directory.CreateDirectory(fileInfo.Directory.ToString());
112+
}
113+
//File.WriteAllBytes(filePath, buf);
114+
BinaryWriter write = new BinaryWriter(new FileStream(filePath, FileMode.Create));
115+
write.Write(buf, 0, buf.Length);
116+
write.Flush();
117+
write.Close();
118+
119+
}
120+
121+
122+
public void createDiskHandle()
123+
{
124+
diskHandle = CreateFile(
125+
"\\\\.\\"+diskLetter+":",
126+
GENERIC_READ,
127+
FILE_SHARE_READ | FILE_SHARE_WRITE,
128+
0,
129+
OPEN_EXISTING,
130+
FILE_ATTRIBUTE_NORMAL,
131+
0);
132+
133+
if (diskHandle == INVALID_HANDLE_VALUE)
134+
{
135+
/*TO DO:
136+
throw and handle exceptions
137+
*/
138+
throw new Exception("ERROR MESSAGE");
139+
}
140+
}
141+
}
142+
}
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Threading.Tasks;
6+
using System.Runtime.InteropServices;
7+
using System.IO;
8+
using System.Management;
9+
using System.Diagnostics;
10+
11+
namespace DiskManager
12+
{
13+
public class WPDiskChecker
14+
{
15+
static string EFIESP_DRIVE;
16+
static string DATA_DRIVE;
17+
static string MAINOS_DRIVE;
18+
static string EFIESP_PHYSICAL;
19+
static string DATA_PHYSICAL;
20+
static string MAINOS_PHYSICAL;
21+
static string EFIESP_NAME;
22+
static string DATA_NAME;
23+
static string MAINOS_NAME;
24+
static string EFIESP_FILESYSTEM;
25+
static string DATA_FILESYSTEM;
26+
static string MAINOS_FILESYSTEM;
27+
28+
public static string[] CheckForDiskInfo()
29+
{
30+
StringBuilder sbmain = new StringBuilder();
31+
sbmain.Append("");
32+
StringBuilder sbdata = new StringBuilder();
33+
sbdata.Append("");
34+
StringBuilder sbefi = new StringBuilder();
35+
sbefi.Append("");
36+
37+
38+
// ADD FREE SPACE AND CAPACITY //
39+
40+
var driveQuery = new ManagementObjectSearcher("select * from Win32_DiskDrive");
41+
foreach (ManagementObject d in driveQuery.Get())
42+
{
43+
var deviceId = d.Properties["DeviceId"].Value;
44+
//Console.WriteLine("Device");
45+
//Console.WriteLine(d);
46+
var partitionQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_DiskDriveToDiskPartition", d.Path.RelativePath);
47+
var partitionQuery = new ManagementObjectSearcher(partitionQueryText);
48+
foreach (ManagementObject p in partitionQuery.Get())
49+
{
50+
//Console.WriteLine("Partition");
51+
//Console.WriteLine(p);
52+
var logicalDriveQueryText = string.Format("associators of {{{0}}} where AssocClass = Win32_LogicalDiskToPartition", p.Path.RelativePath);
53+
var logicalDriveQuery = new ManagementObjectSearcher(logicalDriveQueryText);
54+
foreach (ManagementObject ld in logicalDriveQuery.Get())
55+
{
56+
//Console.WriteLine("Logical drive");
57+
//Console.WriteLine(ld);
58+
59+
var physicalName = Convert.ToString(d.Properties["Name"].Value); // \\.\PHYSICALDRIVE2
60+
var diskName = Convert.ToString(d.Properties["Caption"].Value); // WDC WD5001AALS-xxxxxx
61+
var diskModel = Convert.ToString(d.Properties["Model"].Value); // WDC WD5001AALS-xxxxxx
62+
var diskInterface = Convert.ToString(d.Properties["InterfaceType"].Value); // IDE
63+
var capabilities = (UInt16[])d.Properties["Capabilities"].Value; // 3,4 - random access, supports writing
64+
var mediaLoaded = Convert.ToBoolean(d.Properties["MediaLoaded"].Value); // bool
65+
var mediaType = Convert.ToString(d.Properties["MediaType"].Value); // Fixed hard disk media
66+
var mediaSignature = Convert.ToUInt32(d.Properties["Signature"].Value); // int32
67+
var mediaStatus = Convert.ToString(d.Properties["Status"].Value); // OK
68+
69+
var driveName = Convert.ToString(ld.Properties["Name"].Value); // C:
70+
var driveId = Convert.ToString(ld.Properties["DeviceId"].Value); // C:
71+
var driveCompressed = Convert.ToBoolean(ld.Properties["Compressed"].Value);
72+
var driveType = Convert.ToUInt32(ld.Properties["DriveType"].Value); // C: - 3
73+
var fileSystem = Convert.ToString(ld.Properties["FileSystem"].Value); // NTFS
74+
var freeSpace = Convert.ToUInt64(ld.Properties["FreeSpace"].Value); // in bytes
75+
var totalSpace = Convert.ToUInt64(ld.Properties["Size"].Value); // in bytes
76+
var driveMediaType = Convert.ToUInt32(ld.Properties["MediaType"].Value); // c: 12
77+
var volumeName = Convert.ToString(ld.Properties["VolumeName"].Value); // System
78+
var volumeSerial = Convert.ToString(ld.Properties["VolumeSerialNumber"].Value); // 12345678
79+
if (volumeName == "EFIESP")
80+
{
81+
Debug.WriteLine($"EFIESP: {volumeName}");
82+
EFIESP_NAME = volumeName;
83+
Debug.WriteLine($"{physicalName}");
84+
EFIESP_PHYSICAL = physicalName;
85+
Debug.WriteLine($"{driveName}");
86+
EFIESP_DRIVE = driveName;
87+
Debug.WriteLine($"{fileSystem}");
88+
EFIESP_FILESYSTEM = fileSystem;
89+
Debug.WriteLine(new string('-', 79));
90+
}
91+
if (volumeName == "Data")
92+
{
93+
Debug.WriteLine($"Data: {volumeName}");
94+
DATA_NAME = volumeName;
95+
Debug.WriteLine($"{physicalName}");
96+
DATA_PHYSICAL = physicalName;
97+
Debug.WriteLine($"{driveName}");
98+
DATA_DRIVE = driveName;
99+
Debug.WriteLine($"{fileSystem}");
100+
DATA_FILESYSTEM = fileSystem;
101+
Debug.WriteLine(new string('-', 79));
102+
}
103+
if (volumeName == "MainOS")
104+
{
105+
Debug.WriteLine($"MainOS: {volumeName}");
106+
MAINOS_NAME = volumeName;
107+
Debug.WriteLine($"{physicalName}");
108+
MAINOS_PHYSICAL = physicalName;
109+
Debug.WriteLine($"{driveName}");
110+
MAINOS_DRIVE = driveName;
111+
Debug.WriteLine($"{fileSystem}");
112+
MAINOS_FILESYSTEM = fileSystem;
113+
Debug.WriteLine(new string('-', 79));
114+
}
115+
}
116+
}
117+
}
118+
119+
List<string> noresult = null;
120+
if (EFIESP_NAME != "EFIESP")
121+
{
122+
noresult.Add("EFIESP NOT FOUND ABORTING");
123+
return noresult.ToArray();
124+
125+
}
126+
if (DATA_NAME != "DATA")
127+
{
128+
noresult.Add("DATA NOT FOUND ABORTING");
129+
return noresult.ToArray();
130+
}
131+
if (MAINOS_NAME != "MainOS")
132+
{
133+
noresult.Add("MAINOS NOT FOUND ABORTING");
134+
return noresult.ToArray();
135+
}
136+
137+
string[] result =
138+
{
139+
EFIESP_PHYSICAL,
140+
EFIESP_NAME,
141+
EFIESP_DRIVE,
142+
EFIESP_FILESYSTEM,
143+
DATA_PHYSICAL,
144+
DATA_NAME,
145+
DATA_DRIVE,
146+
DATA_FILESYSTEM,
147+
MAINOS_PHYSICAL,
148+
MAINOS_NAME,
149+
MAINOS_DRIVE,
150+
MAINOS_FILESYSTEM
151+
};
152+
153+
154+
return result;
155+
156+
157+
158+
}
159+
}
160+
}

0 commit comments

Comments
 (0)