Skip to content

Commit 2b91e6c

Browse files
committed
PS5 backup library updates, new tools & many fixes
Please check the v16.2 release notes for all changes.
1 parent 00965a9 commit 2b91e6c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+5412
-2279
lines changed

FreeBSDUpdate.zip

30 MB
Binary file not shown.

LatestBuild.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
16.1.0
1+
16.2.0

LinuxUpdate.zip

18.9 MB
Binary file not shown.

PSMultiTools/Classes/PS5Game.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,17 @@ public enum Location
1313

1414
public enum RootLocation
1515
{
16-
Internal,
17-
USB
16+
InternalStorage,
17+
InternalExtendedStorage,
18+
AttachedUSB
19+
}
20+
21+
public enum BackupType
22+
{
23+
LocalFolder,
24+
LocalPKG,
25+
FTPFolder,
26+
FTPPKG
1827
}
1928

2029
public string? GameTitle { get; set; }
@@ -59,7 +68,7 @@ public enum RootLocation
5968

6069
public string? GameContentIDs { get; set; }
6170

62-
public string? GameBackupType { get; set; }
71+
public BackupType? GameBackupType { get; set; }
6372

6473
public Location GameLocation { get; set; }
6574

@@ -75,6 +84,10 @@ public enum RootLocation
7584

7685
public bool? IsInstalled { get; set; }
7786

87+
public bool? DecryptedFilesExist { get; set; }
88+
89+
public bool? FakelibFilesExist { get; set; }
90+
7891
public static string GetGameRegion(string GameID)
7992
{
8093
if (GameID.StartsWith("PPSA"))

PSMultiTools/Classes/Utils.cs

Lines changed: 90 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
using DiscUtils.Iso9660;
77
using FluentFTP;
88
using IronSoftware.Drawing;
9-
using Microsoft.Data.Sqlite;
109
using MsBox.Avalonia;
1110
using MsBox.Avalonia.Enums;
1211
using PSMultiTools.PS5.Tools.Editors;
@@ -22,6 +21,7 @@
2221
using System.Reflection;
2322
using System.Runtime.InteropServices;
2423
using System.Runtime.Versioning;
24+
using System.Security.Cryptography;
2525
using System.Security.Principal;
2626
using System.Text;
2727
using System.Text.RegularExpressions;
@@ -42,7 +42,7 @@ public partial class Utils
4242

4343
private static Process? currentffplayProc;
4444
private static CancellationTokenSource? currentffplayCts;
45-
private static readonly Lock ffplayprocLock = new();
45+
private static readonly object ffplayprocLock = new();
4646

4747
private static readonly HttpClient NewhttpClient = new() { Timeout = Timeout.InfiniteTimeSpan };
4848

@@ -167,7 +167,7 @@ public static void StartAndStreamSoundBytes(byte[] data)
167167
{
168168
if (!proc.HasExited)
169169
{
170-
proc.WaitForExit(2000);
170+
await proc.WaitForExitAsync();
171171
}
172172
}
173173
catch (Exception ex)
@@ -809,7 +809,7 @@ public static string GetPSMultiToolsVersion()
809809
catch { }
810810

811811
// Return current version if one of the methods above failed - Requires change every build!
812-
return "16.1.0";
812+
return "16.2.0";
813813
}
814814

815815
public static async Task<bool> IsPSMultiToolsUpdateAvailable()
@@ -918,71 +918,6 @@ public static async void DownloadAndExecuteUpdater()
918918

919919
#endregion
920920

921-
#region PS5 Related
922-
923-
public static int BlockAppOrGameUpdates(string connectionString, string titleId, string contentVersion, string versionFileUri)
924-
{
925-
using var connection = new SqliteConnection(connectionString);
926-
connection.Open();
927-
928-
using var transaction = connection.BeginTransaction();
929-
try
930-
{
931-
int totalRows = 0;
932-
933-
// Update JSON inside tbl_contentinfo.AppInfoJson using json_set
934-
using (var cmd = connection.CreateCommand())
935-
{
936-
cmd.Transaction = transaction;
937-
cmd.CommandText = @"
938-
UPDATE tbl_contentinfo
939-
SET AppInfoJson = json_set(
940-
AppInfoJson,
941-
'$.CONTENT_VERSION', $contentVersion,
942-
'$.VERSION_FILE_URI', $versionFileUri
943-
)
944-
WHERE titleId = $titleId;
945-
";
946-
cmd.Parameters.AddWithValue("$contentVersion", contentVersion ?? string.Empty);
947-
cmd.Parameters.AddWithValue("$versionFileUri", versionFileUri ?? string.Empty);
948-
cmd.Parameters.AddWithValue("$titleId", titleId);
949-
950-
totalRows += cmd.ExecuteNonQuery();
951-
}
952-
953-
// Update tbl_appinfo columns
954-
using (var cmd = connection.CreateCommand())
955-
{
956-
cmd.Transaction = transaction;
957-
cmd.CommandText = @"
958-
UPDATE tbl_appinfo
959-
SET VERSION_FILE_URI = $versionFileUri,
960-
CONTENT_VERSION = $contentVersion
961-
WHERE titleId = $titleId;
962-
";
963-
cmd.Parameters.AddWithValue("$versionFileUri", versionFileUri ?? string.Empty);
964-
cmd.Parameters.AddWithValue("$contentVersion", contentVersion ?? string.Empty);
965-
cmd.Parameters.AddWithValue("$titleId", titleId);
966-
967-
totalRows += cmd.ExecuteNonQuery();
968-
}
969-
970-
transaction.Commit();
971-
return totalRows;
972-
}
973-
catch
974-
{
975-
try { transaction.Rollback(); } catch { }
976-
throw;
977-
}
978-
finally
979-
{
980-
connection.Close();
981-
}
982-
}
983-
984-
#endregion
985-
986921
public static bool IncrementArray(ref byte[] sourceArray, int position)
987922
{
988923
if (sourceArray[position] == 255)
@@ -1616,6 +1551,92 @@ public static int GetIntOnly(string Value)
16161551

16171552
#endregion
16181553

1554+
#region FileHashCalculators
1555+
1556+
public static string CRC32Hex(uint crc) => crc.ToString("X8");
1557+
public static readonly uint[] CRCTable = MakeCRCTable();
1558+
1559+
public static uint ComputeCRC32(Stream stream)
1560+
{
1561+
var table = CRCTable;
1562+
uint crc = 0xFFFFFFFFu;
1563+
int b;
1564+
while ((b = stream.ReadByte()) != -1)
1565+
{
1566+
crc = (crc >> 8) ^ table[(crc ^ (byte)b) & 0xFF];
1567+
}
1568+
return crc ^ 0xFFFFFFFFu;
1569+
}
1570+
1571+
public static string ComputeMD5Hex(Stream stream)
1572+
{
1573+
using var md5 = MD5.Create();
1574+
var hash = md5.ComputeHash(stream);
1575+
return ToHex(hash);
1576+
}
1577+
1578+
public static string ComputeSHA1Hex(Stream stream)
1579+
{
1580+
using var sha1 = SHA1.Create();
1581+
var hash = sha1.ComputeHash(stream);
1582+
return ToHex(hash);
1583+
}
1584+
1585+
public static uint ComputeCRC32(string filePath)
1586+
{
1587+
using var fs = File.OpenRead(filePath);
1588+
return ComputeCRC32(fs);
1589+
}
1590+
1591+
public static string ComputeMD5Hex(string filePath)
1592+
{
1593+
using var fs = File.OpenRead(filePath);
1594+
return ComputeMD5Hex(fs);
1595+
}
1596+
1597+
public static string ComputeSHA1Hex(string filePath)
1598+
{
1599+
using var fs = File.OpenRead(filePath);
1600+
return ComputeSHA1Hex(fs);
1601+
}
1602+
1603+
public static (uint sourceCrc, uint targetCrc, uint patchCrc) ReadBPSFooterCRCs(string patchPath)
1604+
{
1605+
byte[] footer = new byte[12];
1606+
using var fs = File.OpenRead(patchPath);
1607+
if (fs.Length < 12) throw new InvalidDataException("Patch file too small to contain footer CRCs");
1608+
fs.Seek(-12, SeekOrigin.End);
1609+
int read = fs.Read(footer, 0, 12);
1610+
if (read != 12) throw new IOException("Failed to read footer");
1611+
uint src = BitConverter.ToUInt32(footer, 0);
1612+
uint tgt = BitConverter.ToUInt32(footer, 4);
1613+
uint pch = BitConverter.ToUInt32(footer, 8);
1614+
return (src, tgt, pch);
1615+
}
1616+
1617+
static string ToHex(byte[] bytes)
1618+
{
1619+
var sb = new StringBuilder(bytes.Length * 2);
1620+
foreach (var b in bytes) sb.Append(b.ToString("X2"));
1621+
return sb.ToString();
1622+
}
1623+
1624+
static uint[] MakeCRCTable()
1625+
{
1626+
const uint poly = 0xEDB88320u;
1627+
var table = new uint[256];
1628+
for (uint i = 0; i < 256; i++)
1629+
{
1630+
uint v = i;
1631+
for (int j = 0; j < 8; j++)
1632+
v = (v & 1) != 0 ? (poly ^ (v >> 1)) : (v >> 1);
1633+
table[i] = v;
1634+
}
1635+
return table;
1636+
}
1637+
1638+
#endregion
1639+
16191640
}
16201641

16211642
}
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
<Window xmlns="https://github.com/avaloniaui"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="310"
6-
x:Class="PSMultiTools.Dialogs.CopyWindow"
7-
Title="Copying" Height="310" Width="550" CanResize="False" CanMinimize="True" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8-
<Grid>
9-
<Image x:Name="GameIconImage" Height="176" HorizontalAlignment="Left" VerticalAlignment="Top" Width="320" Margin="0,0,0,0"/>
10-
11-
<TextBlock x:Name="StatusTextBlock" HorizontalAlignment="Left" Margin="10,203,0,0" Text="Please wait ..." VerticalAlignment="Top" FontSize="14" Width="520"/>
12-
<ProgressBar x:Name="CopyProgressBar" HorizontalAlignment="Left" Height="20" Margin="10,230,0,0" VerticalAlignment="Top" Width="520" />
13-
<TextBlock x:Name="StatusTextBlock2" HorizontalAlignment="Left" Margin="10,260,0,0" Text="Please wait ..." VerticalAlignment="Top" FontSize="14" Width="520"/>
14-
</Grid>
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="550" d:DesignHeight="310"
6+
x:Class="PSMultiTools.Dialogs.CopyWindow"
7+
Title="Copying" Height="310" Width="550" CanResize="False" CanMinimize="True" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8+
<Grid>
9+
<Image x:Name="GameIconImage" Height="176" HorizontalAlignment="Left" VerticalAlignment="Top" Width="320" Margin="0,0,0,0"/>
10+
<TextBlock x:Name="StatusTextBlock" HorizontalAlignment="Left" Margin="10,203,0,0" Text="Please wait ..." VerticalAlignment="Top" FontSize="14" Width="520"/>
11+
<ProgressBar x:Name="CopyProgressBar" HorizontalAlignment="Left" Height="20" Margin="10,230,0,0" VerticalAlignment="Top" Width="520" />
12+
<TextBlock x:Name="StatusTextBlock2" HorizontalAlignment="Left" Margin="10,260,0,0" Text="Please wait ..." VerticalAlignment="Top" FontSize="14" Width="520"/>
13+
</Grid>
1514
</Window>
Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
<Window xmlns="https://github.com/avaloniaui"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="405" d:DesignHeight="120"
6-
x:Class="PSMultiTools.Dialogs.CustomDialog"
7-
Title="Dialog Title" Height="120" Width="405" WindowStartupLocation="CenterScreen" CanResize="False" CanMinimize="True" RequestedThemeVariant="Dark">
8-
<Grid>
9-
<Grid x:Name="TextInputGrid" IsVisible="False">
10-
<TextBlock x:Name="TextInputTitle" HorizontalAlignment="Left" Margin="10,15,0,0" Text="Text" VerticalAlignment="Top" FontFamily="Calibri" FontSize="14"/>
11-
<TextBox x:Name="TextInputTextBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="380" FontFamily="Calibri" FontSize="14" Margin="10,37,0,0"/>
12-
<Button x:Name="TextInputCancelButton" Content="Cancel" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="240,75,0,0" VerticalAlignment="Top" Width="70" FontFamily="Calibri" FontSize="14" Click="TextInputCancelButton_Click"/>
13-
<Button x:Name="TextInputOKButton" Content="OK" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="320,75,0,0" VerticalAlignment="Top" Width="70" FontWeight="Bold" FontFamily="Calibri" FontSize="14" Click="TextInputOKButton_Click"/>
14-
</Grid>
15-
<Grid x:Name="ButtonsGrid" IsVisible="False">
16-
<TextBlock x:Name="ButtonsTitleTextBlock" HorizontalAlignment="Left" Margin="10,20,0,0" Text="Text" VerticalAlignment="Top" FontFamily="Calibri" FontSize="14" Width="375" FontWeight="Bold"/>
17-
<Button x:Name="ButtonsAddButton" Content="Add another backup folder" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top" Width="175" FontFamily="Calibri" FontSize="14" Click="ButtonsAddButton_Click"/>
18-
<Button x:Name="ButtonsLoadNewButton" Content="Load a new folder" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="190,50,0,0" VerticalAlignment="Top" Width="124" FontFamily="Calibri" FontSize="14" Click="ButtonsLoadNewButton_Click"/>
19-
<Button x:Name="ButtonsCancelButton" Content="Cancel" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="320,50,0,0" VerticalAlignment="Top" Width="75" FontFamily="Calibri" FontSize="14" Click="ButtonsCancelButton_Click"/>
20-
</Grid>
21-
</Grid>
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="405" d:DesignHeight="120"
6+
x:Class="PSMultiTools.Dialogs.CustomDialog"
7+
Title="Dialog Title" Height="120" Width="405" WindowStartupLocation="CenterScreen" CanResize="False" CanMinimize="True" RequestedThemeVariant="Dark">
8+
<Grid>
9+
<Grid x:Name="TextInputGrid" IsVisible="False">
10+
<TextBlock x:Name="TextInputTitle" HorizontalAlignment="Left" Margin="10,15,0,0" Text="Text" VerticalAlignment="Top" FontFamily="Calibri" FontSize="14"/>
11+
<TextBox x:Name="TextInputTextBox" HorizontalAlignment="Left" VerticalAlignment="Top" Width="380" FontFamily="Calibri" FontSize="14" Margin="10,37,0,0"/>
12+
<Button x:Name="TextInputCancelButton" Content="Cancel" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="240,75,0,0" VerticalAlignment="Top" Width="70" FontFamily="Calibri" FontSize="14" Click="TextInputCancelButton_Click"/>
13+
<Button x:Name="TextInputOKButton" Content="OK" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="320,75,0,0" VerticalAlignment="Top" Width="70" FontWeight="Bold" FontFamily="Calibri" FontSize="14" Click="TextInputOKButton_Click"/>
14+
</Grid>
15+
<Grid x:Name="ButtonsGrid" IsVisible="False">
16+
<TextBlock x:Name="ButtonsTitleTextBlock" HorizontalAlignment="Left" Margin="10,20,0,0" Text="Text" VerticalAlignment="Top" FontFamily="Calibri" FontSize="14" Width="375" FontWeight="Bold"/>
17+
<Button x:Name="ButtonsAddButton" Content="Add another backup folder" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top" Width="175" FontFamily="Calibri" FontSize="14" Click="ButtonsAddButton_Click"/>
18+
<Button x:Name="ButtonsLoadNewButton" Content="Load a new folder" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="190,50,0,0" VerticalAlignment="Top" Width="124" FontFamily="Calibri" FontSize="14" Click="ButtonsLoadNewButton_Click"/>
19+
<Button x:Name="ButtonsCancelButton" Content="Cancel" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="320,50,0,0" VerticalAlignment="Top" Width="75" FontFamily="Calibri" FontSize="14" Click="ButtonsCancelButton_Click"/>
20+
</Grid>
21+
</Grid>
2222
</Window>
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Window xmlns="https://github.com/avaloniaui"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="340" d:DesignHeight="150"
6-
x:Class="PSMultiTools.Dialogs.InputDialog"
7-
Title="Please enter a new value" Height="150" Width="340" CanResize="False" CanMinimize="True" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8-
<Grid>
9-
<TextBlock x:Name="InputDialogTitleTextBlock" HorizontalAlignment="Left" Margin="20,20,0,0" Text="Enter a new value :" VerticalAlignment="Top" FontSize="14"/>
10-
<TextBox x:Name="NewValueTextBox" HorizontalAlignment="Left" Margin="20,50,0,0" VerticalAlignment="Top" Width="300"/>
11-
<Button x:Name="ConfirmButton" Content="Confirm" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="220,100,0,0" VerticalAlignment="Top" Width="100" Click="ConfirmButton_Click"/>
12-
</Grid>
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="340" d:DesignHeight="150"
6+
x:Class="PSMultiTools.Dialogs.InputDialog"
7+
Title="Please enter a new value" Height="150" Width="340" CanResize="False" CanMinimize="True" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8+
<Grid>
9+
<TextBlock x:Name="InputDialogTitleTextBlock" HorizontalAlignment="Left" Margin="20,20,0,0" Text="Enter a new value :" VerticalAlignment="Top" FontSize="14"/>
10+
<TextBox x:Name="NewValueTextBox" HorizontalAlignment="Left" Margin="20,50,0,0" VerticalAlignment="Top" Width="300"/>
11+
<Button x:Name="ConfirmButton" Content="Confirm" HorizontalContentAlignment="Center" HorizontalAlignment="Left" Margin="220,100,0,0" VerticalAlignment="Top" Width="100" Click="ConfirmButton_Click"/>
12+
</Grid>
1313
</Window>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Window xmlns="https://github.com/avaloniaui"
2-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
mc:Ignorable="d" d:DesignWidth="420" d:DesignHeight="100"
6-
x:Class="PSMultiTools.Dialogs.SyncWindow"
7-
Title="SyncWindow" Height="100" Width="420" CanMinimize="True" CanResize="False" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8-
<Grid>
9-
<TextBlock x:Name="LoadStatusTextBlock" HorizontalAlignment="Left" Margin="10,20,0,0" Text="Loading files x / x" VerticalAlignment="Top" FontSize="16" Width="400"/>
10-
<ProgressBar x:Name="LoadProgressBar" HorizontalAlignment="Left" Height="25" Margin="10,50,0,0" VerticalAlignment="Top" Width="400" />
11-
</Grid>
2+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
3+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
mc:Ignorable="d" d:DesignWidth="420" d:DesignHeight="100"
6+
x:Class="PSMultiTools.Dialogs.SyncWindow"
7+
Title="SyncWindow" Height="100" Width="420" CanMinimize="True" CanResize="False" WindowStartupLocation="CenterScreen" RequestedThemeVariant="Dark">
8+
<Grid>
9+
<TextBlock x:Name="LoadStatusTextBlock" HorizontalAlignment="Left" Margin="10,20,0,0" Text="Loading files x / x" VerticalAlignment="Top" FontSize="16" Width="400"/>
10+
<ProgressBar x:Name="LoadProgressBar" HorizontalAlignment="Left" Height="25" Margin="10,50,0,0" VerticalAlignment="Top" Width="400" />
11+
</Grid>
1212
</Window>

0 commit comments

Comments
 (0)