Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0ef06c36e9 | ||
|
|
c1c25b5f5e | ||
|
|
c175fedbdb | ||
|
|
f7879bf9e8 | ||
|
|
fed9d6ea57 | ||
|
|
41946b6bc5 | ||
|
|
d585c4b534 | ||
|
|
1886e14a9b | ||
|
|
e8f4d88711 | ||
|
|
0dbc483a91 | ||
|
|
b6bb5f0582 | ||
|
|
ea3f6d3f96 | ||
|
|
4aa6aca25e | ||
|
|
a93c727ba2 | ||
|
|
55cab8202d | ||
|
|
1fa7380f06 | ||
|
|
a0acd91a55 | ||
|
|
6edb959e49 | ||
|
|
96b36fcabe | ||
|
|
9d03dbb7b1 | ||
|
|
c7b49d0c80 | ||
|
|
5ce81f9663 | ||
|
|
f74220efea | ||
|
|
6e529f0050 | ||
|
|
b862057123 | ||
|
|
cf19596ea7 | ||
|
|
6af41a9bb3 | ||
|
|
89c23622bd | ||
|
|
8ab6a9d694 | ||
|
|
bc3df52e75 |
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
[submodule "DiscUtils"]
|
[submodule "DiscUtils"]
|
||||||
path = DiscUtils
|
path = LibIRD/DiscUtils
|
||||||
url = https://github.com/Deterous/DiscUtils
|
url = https://github.com/Deterous/DiscUtils
|
||||||
|
|||||||
-1
Submodule DiscUtils deleted from a99992e5f4
+11
-7
@@ -5,11 +5,13 @@
|
|||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetName>irdkit</TargetName>
|
<TargetName>irdkit</TargetName>
|
||||||
<AssemblyName>irdkit</AssemblyName>
|
<AssemblyName>irdkit</AssemblyName>
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||||
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<Version>0.4.0</Version>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Version>0.9.1</Version>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
<Authors>Deterous</Authors>
|
<Authors>Deterous</Authors>
|
||||||
@@ -27,11 +29,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\LibIRD\LibIRD.csproj" />
|
|
||||||
<ProjectReference Include="..\DiscUtils\Library\DiscUtils.Core\DiscUtils.Core.csproj" />
|
|
||||||
<ProjectReference Include="..\DiscUtils\Library\DiscUtils.Iso9660\DiscUtils.Iso9660.csproj" />
|
|
||||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||||
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.2" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.1.4" />
|
||||||
|
<PackageReference Include="SabreTools.RedumpLib" Version="1.3.4" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\LibIRD\LibIRD.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+253
-93
@@ -1,16 +1,14 @@
|
|||||||
using CommandLine;
|
using System;
|
||||||
using DiscUtils;
|
|
||||||
using DiscUtils.Iso9660;
|
|
||||||
using LibIRD;
|
|
||||||
using SabreTools.RedumpLib.Web;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
using System.IO.Hashing;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using CommandLine;
|
||||||
|
using LibIRD;
|
||||||
|
using SabreTools.Hashing;
|
||||||
|
using SabreTools.RedumpLib.Web;
|
||||||
|
|
||||||
namespace IRDKit
|
namespace IRDKit
|
||||||
{
|
{
|
||||||
@@ -24,14 +22,14 @@ namespace IRDKit
|
|||||||
[Verb("create", HelpText = "Create an IRD from an ISO")]
|
[Verb("create", HelpText = "Create an IRD from an ISO")]
|
||||||
public class CreateOptions
|
public class CreateOptions
|
||||||
{
|
{
|
||||||
[Value(0, Required = true, HelpText = "Path to an ISO file, or directory of ISO files")]
|
[Value(0, Required = true, HelpText = "Path to ISO file(s), or directory of ISO files")]
|
||||||
public IEnumerable<string> ISOPath { get; set; }
|
public IEnumerable<string> ISOPath { get; set; }
|
||||||
|
|
||||||
[Option('o', "output", HelpText = "Path to the IRD file to be created (will overwrite)")]
|
[Option('o', "output", HelpText = "Path to the IRD file to be created (will overwrite)")]
|
||||||
public string IRDPath { get; set; }
|
public string IRDPath { get; set; }
|
||||||
|
|
||||||
[Option('b', "layerbreak", HelpText = "Layerbreak value in bytes (use with BD-Video hybrid discs). Default: 12219392")]
|
[Option('b', "layerbreak", HelpText = "Layerbreak value in bytes (use with BD-Video hybrid discs). Default: 12219392")]
|
||||||
public long? Layerbreak { get; set; }
|
public long? Layerbreak { get; set; }
|
||||||
|
|
||||||
[Option('k', "key", HelpText = "Hexadecimal representation of the disc key")]
|
[Option('k', "key", HelpText = "Hexadecimal representation of the disc key")]
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
@@ -55,7 +53,7 @@ namespace IRDKit
|
|||||||
[Verb("info", HelpText = "Print information from an IRD or ISO")]
|
[Verb("info", HelpText = "Print information from an IRD or ISO")]
|
||||||
public class InfoOptions
|
public class InfoOptions
|
||||||
{
|
{
|
||||||
[Value(0, Required = true, HelpText = "Path to an IRD or ISO file, or directory of IRD and/or ISO files")]
|
[Value(0, Required = true, HelpText = "Path to IRD/ISO file(s), or directory of IRD/ISO files")]
|
||||||
public IEnumerable<string> InPath { get; set; }
|
public IEnumerable<string> InPath { get; set; }
|
||||||
|
|
||||||
[Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")]
|
[Option('o', "output", HelpText = "Path to the text or json file to be created (will overwrite)")]
|
||||||
@@ -68,9 +66,9 @@ namespace IRDKit
|
|||||||
public bool Recurse { get; set; }
|
public bool Recurse { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// IRD diff command
|
/// IRD diff command
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Verb("diff", HelpText = "Compare two IRDs and print their differences")]
|
[Verb("diff", HelpText = "Compare two IRDs and print their differences")]
|
||||||
public class DiffOptions
|
public class DiffOptions
|
||||||
{
|
{
|
||||||
@@ -84,6 +82,34 @@ namespace IRDKit
|
|||||||
public string OutPath { get; set; }
|
public string OutPath { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// IRD rename command
|
||||||
|
/// </summary>
|
||||||
|
[Verb("rename", HelpText = "Rename one or more IRD files according to the redump PS3 DAT")]
|
||||||
|
public class RenameOptions
|
||||||
|
{
|
||||||
|
[Value(0, Required = true, HelpText = "Path to IRD file(s), or directory of IRD files")]
|
||||||
|
public IEnumerable<string> IRDPath { get; set; }
|
||||||
|
|
||||||
|
[Option('d', "datfile", Required = true, HelpText = "Path to the redump PS3 Datfile")]
|
||||||
|
public string DATPath { get; set; }
|
||||||
|
|
||||||
|
[Option('s', "serial", HelpText = "Appends disc serial to new IRD filename")]
|
||||||
|
public bool Serial { get; set; }
|
||||||
|
|
||||||
|
[Option('e', "version", HelpText = "Appends disc version to new IRD filename")]
|
||||||
|
public bool Ver { get; set; }
|
||||||
|
|
||||||
|
[Option('c', "crc", HelpText = "Appends ISO CRC to new IRD filename")]
|
||||||
|
public bool CRC { get; set; }
|
||||||
|
|
||||||
|
[Option('r', "recurse", HelpText = "Recurse through all subdirectories and rename all IRDs")]
|
||||||
|
public bool Recurse { get; set; }
|
||||||
|
|
||||||
|
[Option('v', "verbose", HelpText = "Print more information about the renaming")]
|
||||||
|
public bool Verbose { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Program
|
#region Program
|
||||||
@@ -98,7 +124,7 @@ namespace IRDKit
|
|||||||
Console.OutputEncoding = Encoding.UTF8;
|
Console.OutputEncoding = Encoding.UTF8;
|
||||||
|
|
||||||
// Parse arguments
|
// Parse arguments
|
||||||
var result = Parser.Default.ParseArguments<CreateOptions, InfoOptions, DiffOptions>(args).WithParsed(Run);
|
var result = Parser.Default.ParseArguments<CreateOptions, InfoOptions, DiffOptions, RenameOptions>(args).WithParsed(Run);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -159,11 +185,13 @@ namespace IRDKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Determine output IRD folder
|
// Determine output IRD folder
|
||||||
string outputPath = Path.GetDirectoryName(opt.IRDPath);
|
string outputPath = opt.IRDPath;
|
||||||
|
if (File.Exists(opt.IRDPath))
|
||||||
|
outputPath = Path.GetDirectoryName(opt.IRDPath);
|
||||||
|
|
||||||
// Create an IRD file for all ISO files found
|
// Create an IRD file for all ISO files found
|
||||||
foreach (string file in isoFiles)
|
foreach (string file in isoFiles.OrderBy(x => x))
|
||||||
ISO2IRD(file, irdPath: outputPath, verbose: opt.Verbose);
|
ISO2IRD(file, irdPath: outputPath, keyPath: opt.KeyFile, verbose: opt.Verbose);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -171,7 +199,7 @@ namespace IRDKit
|
|||||||
if (!File.Exists(isoPath))
|
if (!File.Exists(isoPath))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"ISO not found: {isoPath}");
|
Console.Error.WriteLine($"ISO not found: {isoPath}");
|
||||||
return;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
string irdPath;
|
string irdPath;
|
||||||
@@ -267,7 +295,7 @@ namespace IRDKit
|
|||||||
{
|
{
|
||||||
PrintISO(file, opt.Json, file.Equals(lastISO), opt.OutPath);
|
PrintISO(file, opt.Json, file.Equals(lastISO), opt.OutPath);
|
||||||
}
|
}
|
||||||
catch (InvalidFileSystemException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
// Not a valid ISO file despite extension, assume file is an IRD
|
// Not a valid ISO file despite extension, assume file is an IRD
|
||||||
if (!opt.Json)
|
if (!opt.Json)
|
||||||
@@ -328,6 +356,99 @@ namespace IRDKit
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
// Process options from a 'rename' command
|
||||||
|
case RenameOptions opt:
|
||||||
|
|
||||||
|
// Validate required parameters
|
||||||
|
if (opt.IRDPath == null || !opt.IRDPath.Any())
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("Provide a valid IRD path to rename");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read DAT file
|
||||||
|
XDocument datfile = DatParser(opt.DATPath);
|
||||||
|
if (datfile == null)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("Unable to parse DAT file");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (string irdPath in opt.IRDPath)
|
||||||
|
{
|
||||||
|
// Validate IRD path
|
||||||
|
if (string.IsNullOrEmpty(irdPath))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// If directory, search for all ISOs in current directory
|
||||||
|
if (Directory.Exists(irdPath))
|
||||||
|
{
|
||||||
|
// If recurse option enabled, search recursively
|
||||||
|
IEnumerable<string> irdFiles;
|
||||||
|
if (opt.Recurse)
|
||||||
|
{
|
||||||
|
if (opt.Verbose && irdPath == ".")
|
||||||
|
Console.WriteLine($"Recursively renaming IRDs in current directory");
|
||||||
|
else if (opt.Verbose)
|
||||||
|
Console.WriteLine($"Recursively renaming IRDs in {irdPath}");
|
||||||
|
irdFiles = Directory.EnumerateFiles(irdPath, "*.ird", SearchOption.AllDirectories);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (opt.Verbose && irdPath == ".")
|
||||||
|
Console.WriteLine($"Renaming IRDs in current directory");
|
||||||
|
else if (opt.Verbose)
|
||||||
|
Console.WriteLine($"Renaming IRDs in {irdPath}");
|
||||||
|
irdFiles = Directory.EnumerateFiles(irdPath, "*.ird", SearchOption.TopDirectoryOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Warn if no files are found
|
||||||
|
if (!irdFiles.Any())
|
||||||
|
{
|
||||||
|
if (opt.Recurse)
|
||||||
|
Console.Error.WriteLine($"No IRDs found in {irdPath} (ensure .ird extension)");
|
||||||
|
else
|
||||||
|
Console.Error.WriteLine($"No IRDs found in {irdPath} (ensure .ird extension, or try use -r)");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename all IRD files found
|
||||||
|
foreach (string file in irdFiles.OrderBy(x => x))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RenameIRD(file, datfile, serial: opt.Serial, ver: opt.Ver, crc: opt.CRC, verbose: opt.Verbose);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Check that given file exists
|
||||||
|
if (!File.Exists(irdPath))
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine($"IRD not found: {irdPath}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rename provided IRD path
|
||||||
|
try
|
||||||
|
{
|
||||||
|
RenameIRD(irdPath, datfile, serial: opt.Serial, ver: opt.Ver, crc: opt.CRC, verbose: opt.Verbose);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
// Unknown command
|
// Unknown command
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -355,7 +476,7 @@ namespace IRDKit
|
|||||||
PrintISO(inPath, json, single, outPath);
|
PrintISO(inPath, json, single, outPath);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (InvalidFileSystemException)
|
catch (IOException)
|
||||||
{
|
{
|
||||||
// Not a valid ISO file despite extension, try open as IRD
|
// Not a valid ISO file despite extension, try open as IRD
|
||||||
}
|
}
|
||||||
@@ -405,18 +526,18 @@ namespace IRDKit
|
|||||||
// Open ISO file for reading
|
// Open ISO file for reading
|
||||||
using FileStream fs = new(isoPath, FileMode.Open, FileAccess.Read);
|
using FileStream fs = new(isoPath, FileMode.Open, FileAccess.Read);
|
||||||
// Validate ISO file stream
|
// Validate ISO file stream
|
||||||
if (fs == null || !CDReader.Detect(fs))
|
if (fs == null || !LibIRD.DiscUtils.Iso9660.CDReader.Detect(fs))
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine($"{isoPath} is not a valid ISO file");
|
Console.Error.WriteLine($"{isoPath} is not a valid ISO file");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Create new ISO reader
|
// Create new ISO reader
|
||||||
using CDReader reader = new(fs, true, true);
|
using LibIRD.DiscUtils.Iso9660.CDReader reader = new(fs);
|
||||||
|
|
||||||
// Write PS3_DISC.SFB info
|
// Write PS3_DISC.SFB info
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using DiscUtils.Streams.SparseStream s = reader.OpenFile("\\PS3_DISC.SFB", FileMode.Open, FileAccess.Read);
|
using LibIRD.DiscUtils.Streams.SparseStream s = reader.OpenFile("\\PS3_DISC.SFB", FileMode.Open, FileAccess.Read);
|
||||||
PS3_DiscSFB ps3_DiscSFB = new(s);
|
PS3_DiscSFB ps3_DiscSFB = new(s);
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
@@ -453,7 +574,7 @@ namespace IRDKit
|
|||||||
// Write PARAM.SFO info
|
// Write PARAM.SFO info
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using DiscUtils.Streams.SparseStream s = reader.OpenFile("\\PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read);
|
using LibIRD.DiscUtils.Streams.SparseStream s = reader.OpenFile("\\PS3_GAME\\PARAM.SFO", FileMode.Open, FileAccess.Read);
|
||||||
ParamSFO paramSFO = new(s);
|
ParamSFO paramSFO = new(s);
|
||||||
if (json)
|
if (json)
|
||||||
{
|
{
|
||||||
@@ -585,7 +706,7 @@ namespace IRDKit
|
|||||||
for (int i = 0; i < regionCount; i++)
|
for (int i = 0; i < regionCount; i++)
|
||||||
{
|
{
|
||||||
if (!IRD1.RegionHashes[i].SequenceEqual(IRD2.RegionHashes[i]))
|
if (!IRD1.RegionHashes[i].SequenceEqual(IRD2.RegionHashes[i]))
|
||||||
printText.AppendLine($"Region {i} Hash: {Convert.ToHexString(IRD1.RegionHashes[i])} vs {Convert.ToHexString(IRD2.RegionHashes[i])}");
|
printText.AppendLine($"Region {i} Hash: {LibIRD.IRD.ByteArrayToHexString(IRD1.RegionHashes[i])} vs {LibIRD.IRD.ByteArrayToHexString(IRD2.RegionHashes[i])}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Print the difference in number of files, if not 0
|
// Print the difference in number of files, if not 0
|
||||||
@@ -601,7 +722,7 @@ namespace IRDKit
|
|||||||
if (j == -1)
|
if (j == -1)
|
||||||
missingOffsets2.Add(IRD1.FileKeys[i]);
|
missingOffsets2.Add(IRD1.FileKeys[i]);
|
||||||
if (j != -1 && !IRD1.FileHashes[i].SequenceEqual(IRD2.FileHashes[j]))
|
if (j != -1 && !IRD1.FileHashes[i].SequenceEqual(IRD2.FileHashes[j]))
|
||||||
printText.AppendLine($"File Hash at Offset {IRD1.FileKeys[i]}: {Convert.ToHexString(IRD1.FileHashes[i])} vs {Convert.ToHexString(IRD2.FileHashes[j])}");
|
printText.AppendLine($"File Hash at Offset {IRD1.FileKeys[i]}: {LibIRD.IRD.ByteArrayToHexString(IRD1.FileHashes[i])} vs {LibIRD.IRD.ByteArrayToHexString(IRD2.FileHashes[j])}");
|
||||||
}
|
}
|
||||||
for (int i = 0; i < IRD2.FileKeys.Length; i++)
|
for (int i = 0; i < IRD2.FileKeys.Length; i++)
|
||||||
{
|
{
|
||||||
@@ -610,8 +731,10 @@ namespace IRDKit
|
|||||||
missingOffsets1.Add(IRD2.FileKeys[i]);
|
missingOffsets1.Add(IRD2.FileKeys[i]);
|
||||||
}
|
}
|
||||||
// Print the file offsets that differ
|
// Print the file offsets that differ
|
||||||
printText.AppendLine($"File Offsets not Present in {irdPath1}: {string.Join(", ", missingOffsets1)}");
|
if (missingOffsets1.Count > 0)
|
||||||
printText.AppendLine($"File Offsets not Present in {irdPath2}: {string.Join(", ", missingOffsets2)}");
|
printText.AppendLine($"File Offsets not Present in {irdPath1}: {string.Join(", ", missingOffsets1)}");
|
||||||
|
if (missingOffsets2.Count > 0)
|
||||||
|
printText.AppendLine($"File Offsets not Present in {irdPath2}: {string.Join(", ", missingOffsets2)}");
|
||||||
|
|
||||||
// Print any extra config data difference
|
// Print any extra config data difference
|
||||||
if (IRD1.ExtraConfig != IRD2.ExtraConfig)
|
if (IRD1.ExtraConfig != IRD2.ExtraConfig)
|
||||||
@@ -627,15 +750,15 @@ namespace IRDKit
|
|||||||
|
|
||||||
// Print any data 1 key difference
|
// Print any data 1 key difference
|
||||||
if (!IRD1.Data1Key.SequenceEqual(IRD2.Data1Key))
|
if (!IRD1.Data1Key.SequenceEqual(IRD2.Data1Key))
|
||||||
printText.AppendLine($"Data 1 Key: {Convert.ToHexString(IRD1.Data1Key)} vs {Convert.ToHexString(IRD2.Data1Key)}");
|
printText.AppendLine($"Data 1 Key: {LibIRD.IRD.ByteArrayToHexString(IRD1.Data1Key)} vs {LibIRD.IRD.ByteArrayToHexString(IRD2.Data1Key)}");
|
||||||
|
|
||||||
// Print any data 2 key difference
|
// Print any data 2 key difference
|
||||||
if (!IRD1.Data2Key.SequenceEqual(IRD2.Data2Key))
|
if (!IRD1.Data2Key.SequenceEqual(IRD2.Data2Key))
|
||||||
printText.AppendLine($"Data 2 Key: {Convert.ToHexString(IRD1.Data2Key)} vs {Convert.ToHexString(IRD2.Data2Key)}");
|
printText.AppendLine($"Data 2 Key: {LibIRD.IRD.ByteArrayToHexString(IRD1.Data2Key)} vs {LibIRD.IRD.ByteArrayToHexString(IRD2.Data2Key)}");
|
||||||
|
|
||||||
// Print any PIC difference
|
// Print any PIC difference
|
||||||
if (!IRD1.PIC.SequenceEqual(IRD2.PIC))
|
if (!IRD1.PIC.SequenceEqual(IRD2.PIC))
|
||||||
printText.AppendLine($"PIC: {Convert.ToHexString(IRD1.PIC)} vs {Convert.ToHexString(IRD2.PIC)}");
|
printText.AppendLine($"PIC: {LibIRD.IRD.ByteArrayToHexString(IRD1.PIC)} vs {LibIRD.IRD.ByteArrayToHexString(IRD2.PIC)}");
|
||||||
|
|
||||||
// Write formatted string to file if output path provided, otherwise to console
|
// Write formatted string to file if output path provided, otherwise to console
|
||||||
if (outPath != null)
|
if (outPath != null)
|
||||||
@@ -687,7 +810,7 @@ namespace IRDKit
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Get disc key from hex string
|
// Get disc key from hex string
|
||||||
byte[] discKey = Convert.FromHexString(hexKey);
|
byte[] discKey = LibIRD.IRD.HexStringToByteArray(hexKey);
|
||||||
if (discKey == null || discKey.Length != 16)
|
if (discKey == null || discKey.Length != 16)
|
||||||
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
||||||
else
|
else
|
||||||
@@ -700,16 +823,11 @@ namespace IRDKit
|
|||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new reproducible redump-style IRD with a given key file
|
// Create new reproducible redump-style IRD with a given key file
|
||||||
@@ -717,30 +835,30 @@ namespace IRDKit
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// If key directory was given, append filename and .key
|
||||||
|
if (Directory.Exists(keyPath))
|
||||||
|
{
|
||||||
|
keyPath = Path.Combine(keyPath, Path.ChangeExtension(Path.GetFileName(isoPath), ".key"));
|
||||||
|
}
|
||||||
// Read key from .key file
|
// Read key from .key file
|
||||||
byte[] discKey = File.ReadAllBytes(keyPath);
|
byte[] discKey = File.ReadAllBytes(keyPath);
|
||||||
if (discKey == null || discKey.Length != 16)
|
if (discKey == null || discKey.Length != 16)
|
||||||
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Creating {irdPath} with Key: {LibIRD.IRD.ByteArrayToHexString(discKey)}");
|
||||||
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
|
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
|
||||||
Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}");
|
|
||||||
ird1.Write(irdPath);
|
ird1.Write(irdPath);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
ird1.Print();
|
ird1.Print();
|
||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create new reproducible redump-style IRD with a given GetKey log
|
// Create new reproducible redump-style IRD with a given GetKey log
|
||||||
@@ -755,16 +873,11 @@ namespace IRDKit
|
|||||||
ird1.Print();
|
ird1.Print();
|
||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No key provided, try search for .key file
|
// No key provided, try search for .key file
|
||||||
@@ -776,29 +889,24 @@ namespace IRDKit
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Read key from .key file
|
// Read key from .key file
|
||||||
byte[] discKey = File.ReadAllBytes(keyPath);
|
byte[] discKey = File.ReadAllBytes(keyfilePath);
|
||||||
if (discKey == null || discKey.Length != 16)
|
if (discKey == null || discKey.Length != 16)
|
||||||
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
Console.Error.WriteLine($"{hexKey} is not a valid key, detecting key automatically...");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Console.WriteLine($"Creating {irdPath} with Key: {LibIRD.IRD.ByteArrayToHexString(discKey)}");
|
||||||
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
|
IRD ird1 = new ReIRD(isoPath, discKey, layerbreak);
|
||||||
Console.WriteLine($"Creating {irdPath} with Key: {Convert.ToHexString(discKey)}");
|
|
||||||
ird1.Write(irdPath);
|
ird1.Write(irdPath);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
ird1.Print();
|
ird1.Print();
|
||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No key provided, try search for .getkey.log file
|
// No key provided, try search for .getkey.log file
|
||||||
@@ -809,23 +917,18 @@ namespace IRDKit
|
|||||||
// Found .getkey.log file, check it is valid
|
// Found .getkey.log file, check it is valid
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine($"Creating {irdPath} with key from: {getKeyLog}");
|
Console.WriteLine($"Creating {irdPath} with key from: {logfilePath}");
|
||||||
IRD ird1 = new ReIRD(isoPath, getKeyLog);
|
IRD ird1 = new ReIRD(isoPath, logfilePath);
|
||||||
ird1.Write(irdPath);
|
ird1.Write(irdPath);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
ird1.Print();
|
ird1.Print();
|
||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
|
||||||
{
|
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// No key provided, try get key from redump.org
|
// No key provided, try get key from redump.org
|
||||||
@@ -833,20 +936,21 @@ namespace IRDKit
|
|||||||
Console.WriteLine("No key provided... Searching for key on redump.org");
|
Console.WriteLine("No key provided... Searching for key on redump.org");
|
||||||
|
|
||||||
// Compute CRC32 hash
|
// Compute CRC32 hash
|
||||||
byte[] crc32;
|
byte[] crc32 = HashTool.GetFileHashArray(isoPath, HashType.CRC32);
|
||||||
using (FileStream fs = File.OpenRead(isoPath))
|
string crc32String = LibIRD.IRD.ByteArrayToHexString(crc32).ToLowerInvariant();
|
||||||
{
|
|
||||||
Crc32 hasher = new();
|
// Convert to UInt for use as UID in IRD
|
||||||
hasher.Append(fs);
|
Array.Reverse(crc32);
|
||||||
crc32 = hasher.GetCurrentHash();
|
uint crc32UInt = BitConverter.ToUInt32(crc32, 0);
|
||||||
// Change endianness
|
|
||||||
Array.Reverse(crc32);
|
|
||||||
}
|
|
||||||
string crc32_hash = Convert.ToHexString(crc32).ToLower();
|
|
||||||
|
|
||||||
// Search for ISO on redump.org
|
// Search for ISO on redump.org
|
||||||
|
#if !NETFRAMEWORK
|
||||||
RedumpHttpClient redump = new();
|
RedumpHttpClient redump = new();
|
||||||
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32_hash).ConfigureAwait(false).GetAwaiter().GetResult();
|
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32String).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
#else
|
||||||
|
RedumpWebClient redump = new();
|
||||||
|
List<int> ids = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + crc32String);
|
||||||
|
#endif
|
||||||
int id;
|
int id;
|
||||||
if (ids.Count == 0)
|
if (ids.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -856,16 +960,14 @@ namespace IRDKit
|
|||||||
else if (ids.Count > 1)
|
else if (ids.Count > 1)
|
||||||
{
|
{
|
||||||
// More than one result for the CRC32 hash, compute SHA1 hash instead
|
// More than one result for the CRC32 hash, compute SHA1 hash instead
|
||||||
byte[] sha1;
|
string sha1String = HashTool.GetFileHash(isoPath, HashType.SHA1);
|
||||||
using (FileStream fs = File.OpenRead(isoPath))
|
|
||||||
{
|
|
||||||
SHA1 hasher = SHA1.Create();
|
|
||||||
sha1 = hasher.ComputeHash(fs);
|
|
||||||
}
|
|
||||||
string sha1_hash = Convert.ToHexString(sha1).ToLower();
|
|
||||||
|
|
||||||
// Search redump.org for SHA1 hash
|
// Search redump.org for SHA1 hash
|
||||||
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1_hash).ConfigureAwait(false).GetAwaiter().GetResult();
|
#if !NETFRAMEWORK
|
||||||
|
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1String).ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
#else
|
||||||
|
List<int> ids2 = redump.CheckSingleSitePage("http://redump.org/discs/system/ps3/quicksearch/" + sha1String);
|
||||||
|
#endif
|
||||||
if (ids2.Count == 0)
|
if (ids2.Count == 0)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("ISO not found in redump and no valid key provided, cannot create IRD");
|
Console.Error.WriteLine("ISO not found in redump and no valid key provided, cannot create IRD");
|
||||||
@@ -885,7 +987,11 @@ namespace IRDKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Download key file from redump.org
|
// Download key file from redump.org
|
||||||
|
#if !NETFRAMEWORK
|
||||||
byte[] key = redump.GetByteArrayAsync($"http://redump.org/disc/{id}/key").ConfigureAwait(false).GetAwaiter().GetResult();
|
byte[] key = redump.GetByteArrayAsync($"http://redump.org/disc/{id}/key").ConfigureAwait(false).GetAwaiter().GetResult();
|
||||||
|
#else
|
||||||
|
byte[] key = redump.DownloadData($"http://redump.org/disc/{id}/key");
|
||||||
|
#endif
|
||||||
if (key.Length != 16)
|
if (key.Length != 16)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("Invalid key obtained from redump and no valid key provided, cannot create IRD");
|
Console.Error.WriteLine("Invalid key obtained from redump and no valid key provided, cannot create IRD");
|
||||||
@@ -893,28 +999,82 @@ namespace IRDKit
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create IRD with key from redump
|
// Create IRD with key from redump
|
||||||
Console.WriteLine($"Creating {irdPath} with Key from redump.org: {Convert.ToHexString(key)}");
|
Console.WriteLine($"Creating {irdPath} with Key from redump.org: {LibIRD.IRD.ByteArrayToHexString(key)}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
IRD ird = new ReIRD(isoPath, key, layerbreak);
|
IRD ird = new ReIRD(isoPath, key, layerbreak, crc32UInt);
|
||||||
ird.Write(irdPath);
|
ird.Write(irdPath);
|
||||||
if (verbose)
|
if (verbose)
|
||||||
ird.Print();
|
ird.Print();
|
||||||
return irdPath;
|
return irdPath;
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
Console.Error.WriteLine(e.Message + ", failed to create IRD");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
}
|
||||||
|
|
||||||
|
public static XDocument DatParser(string datpath = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(datpath))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return XDocument.Load(datpath);
|
||||||
|
}
|
||||||
|
catch
|
||||||
{
|
{
|
||||||
Console.Error.WriteLine("File not found, failed to create IRD");
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
public static string GetDatFilename(IRD ird, XDocument datfile)
|
||||||
|
{
|
||||||
|
string crc32 = ird.UID.ToString("X8").ToLower();
|
||||||
|
XElement node = datfile.Root.Elements("game").Where(e => e.Element("rom").Attribute("crc").Value == crc32).FirstOrDefault() ?? throw new ArgumentException("Cannot find ISO in redump DAT");
|
||||||
|
return node.Attribute("name").Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void RenameIRD(string irdPath, XDocument datfile, bool serial = false, bool ver = false, bool crc = false, bool verbose = false)
|
||||||
|
{
|
||||||
|
IRD ird = IRD.Read(irdPath);
|
||||||
|
|
||||||
|
if (ird.ExtraConfig != 0x0001)
|
||||||
|
throw new ArgumentException($"{irdPath} is not a redump-style IRD");
|
||||||
|
|
||||||
|
string filename = GetDatFilename(ird, datfile) ?? throw new ArgumentException($"Cannot determine DAT filename for {irdPath}");
|
||||||
|
if (serial)
|
||||||
|
filename += $" [{ird.TitleID.Substring(0, 4).Replace('\0', ' ')}-{ird.TitleID.Substring(4, 5).Replace('\0', ' ')}]";
|
||||||
|
if (ver)
|
||||||
|
filename += $" [{ird.DiscVersion.Replace('\0', ' ')}]";
|
||||||
|
if (crc)
|
||||||
|
filename += $" [{ird.UID:X8}]";
|
||||||
|
|
||||||
|
// Rename irdPath to filename
|
||||||
|
string directory = Path.GetDirectoryName(Path.GetFullPath(filename));
|
||||||
|
string filepath;
|
||||||
|
if (!string.IsNullOrEmpty(directory))
|
||||||
|
filepath = Path.Combine(Path.GetDirectoryName(irdPath), filename + ".ird");
|
||||||
|
else
|
||||||
|
filepath = filename + ".ird";
|
||||||
|
|
||||||
|
// Rename IRD to new name
|
||||||
|
if (irdPath != filepath)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
Console.WriteLine($"Renaming {Path.GetFileName(irdPath)} to {Path.GetFileName(filepath)}");
|
||||||
|
File.Move(irdPath, filepath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
Console.WriteLine($"Skipping {Path.GetFileName(irdPath)}, already named correctly");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region Helper Functions
|
#region Helper Functions
|
||||||
|
|
||||||
|
|||||||
@@ -39,3 +39,9 @@ For all options, run `irdkit help diff`
|
|||||||
|
|
||||||
To compare two IRDs, run `irdkit diff game1.ird game2.ird`
|
To compare two IRDs, run `irdkit diff game1.ird game2.ird`
|
||||||
The comparison can be printed to a file, e.g. `-o out.txt` or `--output=`
|
The comparison can be printed to a file, e.g. `-o out.txt` or `--output=`
|
||||||
|
|
||||||
|
## Renaming IRDs
|
||||||
|
|
||||||
|
For all options, run `irdkit help rename`
|
||||||
|
|
||||||
|
To rename an IRD (or folder of IRDs) according to a redump DAT, run `irdkit rename -d redump.dat game.ird`
|
||||||
|
|||||||
+2
-18
@@ -11,16 +11,12 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
ProjectSection(SolutionItems) = preProject
|
ProjectSection(SolutionItems) = preProject
|
||||||
.gitattributes = .gitattributes
|
.gitattributes = .gitattributes
|
||||||
.gitignore = .gitignore
|
.gitignore = .gitignore
|
||||||
|
.gitmodules = .gitmodules
|
||||||
LICENSE.txt = LICENSE.txt
|
LICENSE.txt = LICENSE.txt
|
||||||
|
publish-irdkit.ps1 = publish-irdkit.ps1
|
||||||
README.md = README.md
|
README.md = README.md
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscUtils.Core", "DiscUtils\Library\DiscUtils.Core\DiscUtils.Core.csproj", "{9E71F5CD-887D-4A61-8460-9F7E8F110B46}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscUtils.Iso9660", "DiscUtils\Library\DiscUtils.Iso9660\DiscUtils.Iso9660.csproj", "{9E1EF05F-388B-42C6-A4E7-98BE20C7C8EC}"
|
|
||||||
EndProject
|
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DiscUtils.Streams", "DiscUtils\Library\DiscUtils.Streams\DiscUtils.Streams.csproj", "{E8D0B8B0-F165-4FA1-AC7B-194F5F48A5F9}"
|
|
||||||
EndProject
|
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -35,18 +31,6 @@ Global
|
|||||||
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{9E71F5CD-887D-4A61-8460-9F7E8F110B46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9E71F5CD-887D-4A61-8460-9F7E8F110B46}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9E71F5CD-887D-4A61-8460-9F7E8F110B46}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9E71F5CD-887D-4A61-8460-9F7E8F110B46}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{9E1EF05F-388B-42C6-A4E7-98BE20C7C8EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{9E1EF05F-388B-42C6-A4E7-98BE20C7C8EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{9E1EF05F-388B-42C6-A4E7-98BE20C7C8EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{9E1EF05F-388B-42C6-A4E7-98BE20C7C8EC}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
{E8D0B8B0-F165-4FA1-AC7B-194F5F48A5F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
|
||||||
{E8D0B8B0-F165-4FA1-AC7B-194F5F48A5F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
|
||||||
{E8D0B8B0-F165-4FA1-AC7B-194F5F48A5F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
|
||||||
{E8D0B8B0-F165-4FA1-AC7B-194F5F48A5F9}.Release|Any CPU.Build.0 = Release|Any CPU
|
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Submodule
+1
Submodule LibIRD/DiscUtils added at 445a572137
+558
-276
File diff suppressed because it is too large
Load Diff
+14
-7
@@ -2,11 +2,12 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<!-- Assembly Properties -->
|
<!-- Assembly Properties -->
|
||||||
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
|
||||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||||
|
<CheckEolTargetFramework>false</CheckEolTargetFramework>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings>
|
||||||
<Version>0.4.0</Version>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
|
<Version>0.9.0</Version>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
@@ -21,15 +22,21 @@
|
|||||||
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
||||||
|
<TargetFrameworks>net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="!$(RuntimeIdentifier.StartsWith(`osx-arm`))">
|
||||||
|
<TargetFrameworks>net20;net35;net40;net452;net462;net472;net48;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="./README.md" Pack="true" PackagePath="" />
|
<None Include="./README.md" Pack="true" PackagePath="" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DiscUtils\Library\DiscUtils.Core\DiscUtils.Core.csproj" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<ProjectReference Include="..\DiscUtils\Library\DiscUtils.Iso9660\DiscUtils.Iso9660.csproj" />
|
<PackageReference Include="SabreTools.Hashing" Version="1.1.4" />
|
||||||
<ProjectReference Include="..\DiscUtils\Library\DiscUtils.Streams\DiscUtils.Streams.csproj" />
|
|
||||||
<PackageReference Include="System.IO.Hashing" Version="8.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace LibIRD
|
namespace LibIRD
|
||||||
{
|
{
|
||||||
@@ -27,7 +27,7 @@ namespace LibIRD
|
|||||||
/// A field within the PS3_DISC.SFB file
|
/// A field within the PS3_DISC.SFB file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>string Key, string Value</remarks>
|
/// <remarks>string Key, string Value</remarks>
|
||||||
public Dictionary<string, string> Field { get; private set; }
|
public Dictionary<string, string> Field { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor using a PARAM.SFO file path
|
/// Constructor using a PARAM.SFO file path
|
||||||
@@ -68,7 +68,7 @@ namespace LibIRD
|
|||||||
// Read SFB file version
|
// Read SFB file version
|
||||||
byte[] buf = br.ReadBytes(2);
|
byte[] buf = br.ReadBytes(2);
|
||||||
Array.Reverse(buf);
|
Array.Reverse(buf);
|
||||||
Version = BitConverter.ToUInt16(buf);
|
Version = BitConverter.ToUInt16(buf, 0);
|
||||||
|
|
||||||
// Process all field headers
|
// Process all field headers
|
||||||
sfbStream.Seek(0x20, SeekOrigin.Begin);
|
sfbStream.Seek(0x20, SeekOrigin.Begin);
|
||||||
@@ -138,7 +138,7 @@ namespace LibIRD
|
|||||||
public void PrintJson(string jsonPath = null)
|
public void PrintJson(string jsonPath = null)
|
||||||
{
|
{
|
||||||
// Serialise PS3_Disc.SFB data to a JSON object
|
// Serialise PS3_Disc.SFB data to a JSON object
|
||||||
string json = JsonSerializer.Serialize(Field, new JsonSerializerOptions { WriteIndented = true });
|
string json = JsonConvert.SerializeObject(Field, Formatting.Indented);
|
||||||
|
|
||||||
// If no path given, output to console
|
// If no path given, output to console
|
||||||
if (jsonPath == null)
|
if (jsonPath == null)
|
||||||
|
|||||||
+6
-11
@@ -2,7 +2,7 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace LibIRD
|
namespace LibIRD
|
||||||
{
|
{
|
||||||
@@ -43,13 +43,8 @@ namespace LibIRD
|
|||||||
/// Constructor using a PARAM.SFO file path
|
/// Constructor using a PARAM.SFO file path
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="sfoPath">Full file path to the PARAM.SFO file</param>
|
/// <param name="sfoPath">Full file path to the PARAM.SFO file</param>
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
|
||||||
public ParamSFO(string sfoPath)
|
public ParamSFO(string sfoPath)
|
||||||
{
|
{
|
||||||
// Validate file path
|
|
||||||
if (sfoPath == null || sfoPath.Length <= 0)
|
|
||||||
throw new ArgumentNullException(nameof(sfoPath));
|
|
||||||
|
|
||||||
// Read file as a stream, and parse file
|
// Read file as a stream, and parse file
|
||||||
using FileStream fs = new(sfoPath, FileMode.Open, FileAccess.Read);
|
using FileStream fs = new(sfoPath, FileMode.Open, FileAccess.Read);
|
||||||
Parse(fs);
|
Parse(fs);
|
||||||
@@ -103,7 +98,7 @@ namespace LibIRD
|
|||||||
- keyOffset[i];
|
- keyOffset[i];
|
||||||
|
|
||||||
// Read ith key name
|
// Read ith key name
|
||||||
string key = Encoding.ASCII.GetString(br.ReadBytes((int) keyLen)).TrimEnd('\0');
|
string key = Encoding.ASCII.GetString(br.ReadBytes((int)keyLen)).TrimEnd('\0');
|
||||||
|
|
||||||
// Move stream to ith data
|
// Move stream to ith data
|
||||||
sfoStream.Position = dataTableStart + dataOffset[i];
|
sfoStream.Position = dataTableStart + dataOffset[i];
|
||||||
@@ -112,13 +107,13 @@ namespace LibIRD
|
|||||||
Field[key] = dataFormat[i] switch
|
Field[key] = dataFormat[i] switch
|
||||||
{
|
{
|
||||||
// Non-null-terminated UTF-8 String
|
// Non-null-terminated UTF-8 String
|
||||||
0x0004 => Encoding.UTF8.GetString(br.ReadBytes((int) dataLength[i])),
|
0x0004 => Encoding.UTF8.GetString(br.ReadBytes((int)dataLength[i])),
|
||||||
// Null-terminated UTF-8 String
|
// Null-terminated UTF-8 String
|
||||||
0x0204 => Encoding.UTF8.GetString(br.ReadBytes((int) dataLength[i])).TrimEnd('\0'),
|
0x0204 => Encoding.UTF8.GetString(br.ReadBytes((int)dataLength[i])).TrimEnd('\0'),
|
||||||
// Integer
|
// Integer
|
||||||
0x0404 => br.ReadInt32().ToString(),
|
0x0404 => br.ReadInt32().ToString(),
|
||||||
// Unknown data format, assume null-terminated string
|
// Unknown data format, assume null-terminated string
|
||||||
_ => Encoding.UTF8.GetString(br.ReadBytes((int) dataLength[i])).TrimEnd('\0'),
|
_ => Encoding.UTF8.GetString(br.ReadBytes((int)dataLength[i])).TrimEnd('\0'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -166,7 +161,7 @@ namespace LibIRD
|
|||||||
public void PrintJson(string jsonPath = null)
|
public void PrintJson(string jsonPath = null)
|
||||||
{
|
{
|
||||||
// Serialise PS3_Disc.SFB data to a JSON object
|
// Serialise PS3_Disc.SFB data to a JSON object
|
||||||
string json = JsonSerializer.Serialize(Field, new JsonSerializerOptions { WriteIndented = true });
|
string json = JsonConvert.SerializeObject(Field, Formatting.Indented);
|
||||||
|
|
||||||
// If no path given, output to console
|
// If no path given, output to console
|
||||||
if (jsonPath == null)
|
if (jsonPath == null)
|
||||||
|
|||||||
+46
-87
@@ -1,8 +1,5 @@
|
|||||||
using DiscUtils.Iso9660;
|
using System;
|
||||||
using System;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Hashing;
|
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
namespace LibIRD
|
namespace LibIRD
|
||||||
{
|
{
|
||||||
@@ -60,12 +57,7 @@ namespace LibIRD
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isoPath">Path to the ISO</param>
|
/// <param name="isoPath">Path to the ISO</param>
|
||||||
/// <param name="getKeyLog">Path to the GetKey log file</param>
|
/// <param name="getKeyLog">Path to the GetKey log file</param>
|
||||||
/// <exception cref="InvalidDataException"></exception>
|
public ReIRD(string isoPath, string getKeyLog) : base(isoPath, getKeyLog, true) { }
|
||||||
public ReIRD(string isoPath, string getKeyLog) : base(isoPath, getKeyLog, true)
|
|
||||||
{
|
|
||||||
// Generate Unique Identifier using ISO CRC32
|
|
||||||
UID = GenerateUID(isoPath);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor with optional additional region to generate a specific Disc ID
|
/// Constructor with optional additional region to generate a specific Disc ID
|
||||||
@@ -73,11 +65,12 @@ namespace LibIRD
|
|||||||
/// <param name="isoPath">Path to the ISO</param>
|
/// <param name="isoPath">Path to the ISO</param>
|
||||||
/// <param name="key">Disc Key, redump-style (AES encrypted Data 1)</param>
|
/// <param name="key">Disc Key, redump-style (AES encrypted Data 1)</param>
|
||||||
/// <param name="layerbreak">Layerbreak value, in sectors</param>
|
/// <param name="layerbreak">Layerbreak value, in sectors</param>
|
||||||
|
/// <param name="uid">Unique ID, crc32 hash of ISO</param>
|
||||||
/// <param name="region">Disc Region</param>
|
/// <param name="region">Disc Region</param>
|
||||||
public ReIRD(string isoPath, byte[] key, long? layerbreak = null, Region region = Region.NONE) : base()
|
public ReIRD(string isoPath, byte[] key, long? layerbreak = null, uint? uid = null, Region region = Region.NONE) : base()
|
||||||
{
|
{
|
||||||
// Generate Unique Identifier using ISO CRC32
|
// If the ISO CRC32 is provided, use it as the Unique ID
|
||||||
UID = GenerateUID(isoPath);
|
UID = uid == null ? 0x00000000 : (uint)uid;
|
||||||
|
|
||||||
// Determine ISO file size
|
// Determine ISO file size
|
||||||
long size = CalculateSize(isoPath);
|
long size = CalculateSize(isoPath);
|
||||||
@@ -136,11 +129,11 @@ namespace LibIRD
|
|||||||
if (layerbreak >= 2 * BDLayerSize || layerbreak % SectorSize != 0)
|
if (layerbreak >= 2 * BDLayerSize || layerbreak % SectorSize != 0)
|
||||||
throw new ArgumentException("Unexpected layerbreak value", nameof(size));
|
throw new ArgumentException("Unexpected layerbreak value", nameof(size));
|
||||||
}
|
}
|
||||||
else
|
else if (size > BDLayerSize)
|
||||||
{
|
{
|
||||||
// If no layerbreak provided, ensure ISO is not BD-Video hybrid
|
// If no layerbreak provided, ensure ISO is not BD-Video hybrid
|
||||||
using FileStream fs = new FileStream(isoPath, FileMode.Open, FileAccess.Read) ?? throw new FileNotFoundException(isoPath);
|
using FileStream fs = new FileStream(isoPath, FileMode.Open, FileAccess.Read) ?? throw new FileNotFoundException(isoPath);
|
||||||
CDReader reader = new(fs, true, true);
|
DiscUtils.Iso9660.CDReader reader = new(fs);
|
||||||
if (reader.DirectoryExists("\\BDMV"))
|
if (reader.DirectoryExists("\\BDMV"))
|
||||||
throw new ArgumentException("Layerbreak must be provided for BD-Video hybrid discs");
|
throw new ArgumentException("Layerbreak must be provided for BD-Video hybrid discs");
|
||||||
// Assume disc has default layerbreak
|
// Assume disc has default layerbreak
|
||||||
@@ -152,62 +145,62 @@ namespace LibIRD
|
|||||||
if (size > BDLayerSize) // if BD-50
|
if (size > BDLayerSize) // if BD-50
|
||||||
{
|
{
|
||||||
// Layer 0 start sector = 0x01000000
|
// Layer 0 start sector = 0x01000000
|
||||||
long l0_start_sector = 1048576;
|
long l0_start_sector = 1048576;
|
||||||
|
|
||||||
// Layer 0 end sector = start sector + layerbreak - 2
|
// Layer 0 end sector = start sector + layerbreak - 2
|
||||||
long l0_end_sector = ((long)layerbreak / SectorSize) + l0_start_sector - 2;
|
long l0_end_sector = ((long)layerbreak / SectorSize) + l0_start_sector - 2;
|
||||||
// Convert end sector location to hex values for PIC
|
// Convert end sector location to hex values for PIC
|
||||||
byte[] l0es = [(byte)((l0_end_sector >> 24) & 0xFF),
|
byte[] l0es = [(byte)((l0_end_sector >> 24) & 0xFF),
|
||||||
(byte)((l0_end_sector >> 16) & 0xFF),
|
(byte)((l0_end_sector >> 16) & 0xFF),
|
||||||
(byte)((l0_end_sector >> 8) & 0xFF),
|
(byte)((l0_end_sector >> 8) & 0xFF),
|
||||||
(byte)((l0_end_sector >> 0) & 0xFF)];
|
(byte)((l0_end_sector >> 0) & 0xFF)];
|
||||||
|
|
||||||
// Layer 1 start sector = end of disc (0x01EFFFFE) - layerbreak + 2
|
// Layer 1 start sector = end of disc (0x01EFFFFE) - layerbreak + 2
|
||||||
long l1_start_sector = 32505854 - ((long)layerbreak! / SectorSize) + 2;
|
long l1_start_sector = 32505854 - ((long)layerbreak! / SectorSize) + 2;
|
||||||
// Convert start of start sector location to hex values for PIC
|
// Convert start of start sector location to hex values for PIC
|
||||||
byte[] l1ss = [(byte)((l1_start_sector >> 24) & 0xFF),
|
byte[] l1ss = [(byte)((l1_start_sector >> 24) & 0xFF),
|
||||||
(byte)((l1_start_sector >> 16) & 0xFF),
|
(byte)((l1_start_sector >> 16) & 0xFF),
|
||||||
(byte)((l1_start_sector >> 8) & 0xFF),
|
(byte)((l1_start_sector >> 8) & 0xFF),
|
||||||
(byte)((l1_start_sector >> 0) & 0xFF)];
|
(byte)((l1_start_sector >> 0) & 0xFF)];
|
||||||
|
|
||||||
// Total sectors used = num_sectors + Layer 0 start + sectors_between_layers (usually 0x01358C00 - 0x00CA73FE - 3)
|
// Total sectors used = num_sectors + Layer 0 start + sectors_between_layers (usually 0x01358C00 - 0x00CA73FE - 3)
|
||||||
long total_sectors = (size / SectorSize) + l0_start_sector + (l1_start_sector - l0_end_sector - 3);
|
long total_sectors = (size / SectorSize) + l0_start_sector + (l1_start_sector - l0_end_sector - 3);
|
||||||
byte[] ts = BitConverter.GetBytes((uint) total_sectors);
|
byte[] ts = BitConverter.GetBytes((uint)total_sectors);
|
||||||
|
|
||||||
// Define the PIC
|
// Define the PIC
|
||||||
pic = [
|
pic = [
|
||||||
// Initial portion of PIC (24 bytes)
|
// Initial portion of PIC (24 bytes)
|
||||||
// [4098 bytes] [2x 0x00] ["DI"] [v1] [10units] [DI num]
|
// [4098 bytes] [2x 0x00] ["DI"] [v1] [10units] [DI num]
|
||||||
0x10, 0x02, 0x00, 0x00, 0x44, 0x49, 0x01, 0x10, 0x00, 0x00, 0x20, 0x00,
|
0x10, 0x02, 0x00, 0x00, 0x44, 0x49, 0x01, 0x10, 0x00, 0x00, 0x20, 0x00,
|
||||||
// ["BDR"] [2 layers]
|
// ["BDR"] [2 layers]
|
||||||
0x42, 0x44, 0x4F, 0x01, 0x21, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x42, 0x44, 0x4F, 0x01, 0x21, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
// Total sectors used on disc (4 bytes)
|
// Total sectors used on disc (4 bytes)
|
||||||
ts[3], ts[2], ts[1], ts[0],
|
ts[3], ts[2], ts[1], ts[0],
|
||||||
// 1st Layer sector start location (4 bytes)
|
// 1st Layer sector start location (4 bytes)
|
||||||
0x00, 0x10, 0x00, 0x00,
|
0x00, 0x10, 0x00, 0x00,
|
||||||
// 1st Layer sector end location (4 bytes), 0x00CA73FE for default BD layerbreak of 12219392
|
// 1st Layer sector end location (4 bytes), 0x00CA73FE for default BD layerbreak of 12219392
|
||||||
l0es[0], l0es[1], l0es[2], l0es[3],
|
l0es[0], l0es[1], l0es[2], l0es[3],
|
||||||
// 32 bytes of zeros
|
// 32 bytes of zeros
|
||||||
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, 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,
|
||||||
// Initial portion of PIC again, for 2nd layer
|
// Initial portion of PIC again, for 2nd layer
|
||||||
// ["DI"] [v1] [11unit][DI num]
|
// ["DI"] [v1] [11unit][DI num]
|
||||||
0x44, 0x49, 0x01, 0x11, 0x00, 0x01, 0x20, 0x00,
|
0x44, 0x49, 0x01, 0x11, 0x00, 0x01, 0x20, 0x00,
|
||||||
// ["BDR"] [2 layers]
|
// ["BDR"] [2 layers]
|
||||||
0x42, 0x44, 0x4F, 0x01, 0x21, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x42, 0x44, 0x4F, 0x01, 0x21, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
// Total sectors used on disc
|
// Total sectors used on disc
|
||||||
ts[3], ts[2], ts[1], ts[0],
|
ts[3], ts[2], ts[1], ts[0],
|
||||||
// 2nd Layer sector start location, 0x01358C00 for default BD layerbreak of 12219392
|
// 2nd Layer sector start location, 0x01358C00 for default BD layerbreak of 12219392
|
||||||
l1ss[0], l1ss[1], l1ss[2], l1ss[3],
|
l1ss[0], l1ss[1], l1ss[2], l1ss[3],
|
||||||
// 2nd Layer sector end location
|
// 2nd Layer sector end location
|
||||||
0x01, 0xEF, 0xFF, 0xFE,
|
0x01, 0xEF, 0xFF, 0xFE,
|
||||||
// Remaining 32 bytes are zeroes
|
// Remaining 32 bytes are zeroes
|
||||||
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 ];
|
||||||
// 3k3y style: 0x03 at last byte
|
// 3k3y style: 0x03 at last byte
|
||||||
if (exactIRD)
|
if (exactIRD)
|
||||||
pic[114] = 0x03;
|
pic[114] = 0x03;
|
||||||
|
|
||||||
}
|
}
|
||||||
else // if BD-25
|
else // if BD-25
|
||||||
{
|
{
|
||||||
// Total sectors used on disc: num_sectors + layer_sector_end (0x00100000) - 1
|
// Total sectors used on disc: num_sectors + layer_sector_end (0x00100000) - 1
|
||||||
@@ -237,45 +230,11 @@ namespace LibIRD
|
|||||||
return pic;
|
return pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Generates the UID field by computing the CRC32 hash of the ISO
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="isoPath">Path to the ISO</param>
|
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
|
||||||
/// <exception cref="FileNotFoundException"></exception>
|
|
||||||
private static uint GenerateUID(string isoPath)
|
|
||||||
{
|
|
||||||
// Check file exists
|
|
||||||
FileInfo iso;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
iso = new FileInfo(isoPath);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
throw new ArgumentException("Invalid ISO Path: " + e.Message);
|
|
||||||
}
|
|
||||||
if (!iso.Exists)
|
|
||||||
throw new FileNotFoundException(nameof(isoPath));
|
|
||||||
|
|
||||||
// Compute CRC32 hash
|
|
||||||
byte[] crc32;
|
|
||||||
using (FileStream fs = File.OpenRead(isoPath))
|
|
||||||
{
|
|
||||||
Crc32 hasher = new();
|
|
||||||
hasher.Append(fs);
|
|
||||||
crc32 = hasher.GetCurrentHash();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Redump ISO CRC32 hash is used as the Unique ID in the reproducible IRD
|
|
||||||
return BitConverter.ToUInt32(crc32, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calculates ISO file size
|
/// Calculates ISO file size
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="isoPath">Path to the ISO</param>
|
/// <param name="isoPath">Path to the ISO</param>
|
||||||
/// <exception cref="ArgumentNullException"></exception>
|
/// <exception cref="ArgumentException"></exception>
|
||||||
/// <exception cref="FileNotFoundException"></exception>
|
/// <exception cref="FileNotFoundException"></exception>
|
||||||
private static long CalculateSize(string isoPath)
|
private static long CalculateSize(string isoPath)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ IRDKit is a tool that allows direct use of LibIRD functionality from a command l
|
|||||||
- Printing info about all ISOs and IRDs in a folder: `irdkit info .`
|
- Printing info about all ISOs and IRDs in a folder: `irdkit info .`
|
||||||
- Creating an IRD from an ISO: `irdkit create game.iso`
|
- Creating an IRD from an ISO: `irdkit create game.iso`
|
||||||
- Finding differences between two IRDs: `irdkit diff game1.ird game2.ird`
|
- Finding differences between two IRDs: `irdkit diff game1.ird game2.ird`
|
||||||
|
- Renaming an IRD or folder of IRDs using a redump DAT: `irdkit rename -d redump.dat game.ird`
|
||||||
|
|
||||||
For detailed usage, read more [here](IRDKit).
|
For detailed usage, read more [here](IRDKit).
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user