From 2fcf5fcae36b399bdda35377e715b6c5d07414fa Mon Sep 17 00:00:00 2001
From: Deterous <138427222+Deterous@users.noreply.github.com>
Date: Fri, 10 Nov 2023 22:09:00 +1300
Subject: [PATCH] Print IRD fields, add a READEME
---
BuildIRD/BuildIRD.cs | 28 +++++-----------------------
LibIRD/IRD.cs | 37 +++++++++++++++++++++++++++++++++++++
LibIRD/LibIRD.csproj | 3 ++-
LibIRD/ParamSFO.cs | 7 +++++--
LibIRD/ReIRD.cs | 2 +-
README.md | 44 +++++++++++++++++++++++++++++++++++++++++++-
6 files changed, 93 insertions(+), 28 deletions(-)
diff --git a/BuildIRD/BuildIRD.cs b/BuildIRD/BuildIRD.cs
index 2a5a06b..8d2bb7f 100644
--- a/BuildIRD/BuildIRD.cs
+++ b/BuildIRD/BuildIRD.cs
@@ -19,41 +19,23 @@ namespace BuildIRD
IRD ird1 = new ReIRD("./game.iso", discKey);
ird1.Write("./test1.ird");
- Console.WriteLine("IRD created using .key:");
-
- // Read IRD and print details to console
- IRD ird = IRD.Read("./test1.ird");
- Console.WriteLine("IRD Version: " + ird.Version);
- Console.WriteLine("Title ID: " + ird.TitleID);
- Console.WriteLine("Title: " + ird.Title);
- Console.WriteLine("System Version: " + ird.SystemVersion);
- Console.WriteLine("Game Version: " + ird.GameVersion);
- Console.WriteLine("App Version: " + ird.AppVersion);
+ ird1.Print();
}
catch (FileNotFoundException e)
{
- Console.WriteLine("File not found: " + e.FileName);
+ Console.WriteLine("ERROR: File not found");
}
- // Create new reproducible redump-style IRD with a GetKey log
+ // Create new reproducible redump-style IRD with a ManaGunZ log
try
{
IRD ird2 = new ReIRD("./game.iso", "./log.getkey.log");
ird2.Write("./test2.ird");
- Console.WriteLine("IRD created using .getkey.log:");
-
- // Read IRD and print details to console
- IRD ird = IRD.Read("./test2.ird");
- Console.WriteLine("IRD Version: " + ird.Version);
- Console.WriteLine("Title ID: " + ird.TitleID);
- Console.WriteLine("Title: " + ird.Title);
- Console.WriteLine("System Version: " + ird.SystemVersion);
- Console.WriteLine("Game Version: " + ird.GameVersion);
- Console.WriteLine("App Version: " + ird.AppVersion);
+ ird2.Print();
}
catch (FileNotFoundException e)
{
- Console.WriteLine("File not found: " + e.FileName);
+ Console.WriteLine("ERROR: File not found");
}
}
}
diff --git a/LibIRD/IRD.cs b/LibIRD/IRD.cs
index f276ad1..dcee529 100644
--- a/LibIRD/IRD.cs
+++ b/LibIRD/IRD.cs
@@ -1242,6 +1242,43 @@ namespace LibIRD
uid);
}
+ ///
+ /// Prints IRD fields to console
+ ///
+ public void Print()
+ {
+ // Build string from parameters
+ StringBuilder print = new();
+ print.AppendLine("IRD Contents:");
+ print.AppendLine("=============");
+
+ // Append IRD fields to string builder
+ print.AppendLine($"Magic: 3IRD");
+ print.AppendLine($"IRD Version: {Version}");
+ print.AppendLine($"Title ID: {TitleID}");
+ print.AppendLine($"Title: {Title}");
+ print.AppendLine($"PUP Version: {SystemVersion}");
+ print.AppendLine($"Game Version: {GameVersion}");
+ print.AppendLine($"App Version: {AppVersion}");
+ print.AppendLine($"Regions: {RegionCount}");
+ print.AppendLine($"Files: {FileCount}");
+ if (ExtraConfig != 0x0000)
+ print.AppendLine($"Extra Config: {ExtraConfig:X4}");
+ if (Attachments != 0x0000)
+ print.AppendLine($"Attachments: {Attachments:X4}");
+ print.AppendLine($"Unique ID: {UID:X8}");
+ print.AppendLine($"Data 1 Key: {Convert.ToHexString(Data1Key)}");
+ print.AppendLine($"Data 2 Key: {Convert.ToHexString(Data2Key)}");
+ print.AppendLine($"PIC: {Convert.ToHexString(PIC)}");
+ print.AppendLine();
+
+ // Ensure UTF-8 will display properly
+ Console.OutputEncoding = Encoding.UTF8;
+
+ // Print formatted string
+ Console.Write(print);
+ }
+
#endregion
}
}
diff --git a/LibIRD/LibIRD.csproj b/LibIRD/LibIRD.csproj
index 00c6f11..251583f 100644
--- a/LibIRD/LibIRD.csproj
+++ b/LibIRD/LibIRD.csproj
@@ -9,7 +9,8 @@
Deterous
Library for ISO Rebuild Data
- Copyright (c)2023 Deterous
+ Copyright (c) Deterous 2023
+ README.MD
https://github.com/Deterous/LibIRD
git
ps3 iso ird
diff --git a/LibIRD/ParamSFO.cs b/LibIRD/ParamSFO.cs
index 8e47b13..fed4dbb 100644
--- a/LibIRD/ParamSFO.cs
+++ b/LibIRD/ParamSFO.cs
@@ -208,7 +208,9 @@ namespace LibIRD
public void Print()
{
// Build string from parameters
- StringBuilder print = new("PARAM.SFO Contents:\n====================\n");
+ StringBuilder print = new();
+ print.AppendLine("PARAM.SFO Contents:");
+ print.AppendLine("====================");
// Loop through all parameters in PARAM.SFO
for (int i = 0; i < ParamCount; i++)
@@ -221,9 +223,10 @@ namespace LibIRD
{
case 0x0404:
print.Append(Params[i].IntValue);
+ print.AppendLine();
break;
default:
- print.Append(Params[i].StringValue);
+ print.AppendLine(Params[i].StringValue);
break;
}
print.Append('\n');
diff --git a/LibIRD/ReIRD.cs b/LibIRD/ReIRD.cs
index 232b7c8..2da95f7 100644
--- a/LibIRD/ReIRD.cs
+++ b/LibIRD/ReIRD.cs
@@ -56,7 +56,7 @@ namespace LibIRD
///
/// ISO file size
///
- public long Size { get; private set; }
+ private long Size { get; set; }
#endregion
diff --git a/README.md b/README.md
index 1a1aebe..6c89ddc 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,43 @@
-# WIP
\ No newline at end of file
+# Library for ISO Rebuild Data (LibIRD)
+
+This .NET library provides methods for generating, writing, and reading IRD files. Functionality is provided for deterministically generating IRDs such that a redump ISO and key have a 1-to-1 correspondence with an unique IRD file.
+
+## How to use LibIRD
+
+### Reproducible, redump-style IRDs
+
+The standard way of generating a reproducible, redump-style IRD with LibIRD is with a redump ISO file and a redump key file (e.g. http://redump.org/disc/28721/key/):
+```
+byte[] discKey = File.ReadAllBytes("./game.key");
+IRD ird = new ReIRD("./game.iso", discKey);
+```
+alternatively, the disc key can be extracted from a [ManaGunZ](https://github.com/Zarh/ManaGunZ/) .getkey.log file:
+```
+IRD ird = new ReIRD("./game.iso", "./game.getkey.log");
+```
+
+### Custom IRDs
+
+Functionality is also provided for creating custom IRDs, with whatever data you want. One way is to use an ISO with a custom disc key, disc ID, and PIC:
+```
+byte[] discKey = new byte[16];
+byte[] discID = new byte[16];
+byte[] PIC = new byte[115];
+// Set vars to desired values
+IRD ird = new IRD("./game.iso", discKey, discID, discPIC);
+```
+As before, a [ManaGunZ](https://github.com/Zarh/ManaGunZ/) log file can also be used with an ISO to create an IRD, with the disc key, disc ID, and PIC all being extracted from the .getkey.log file.
+```
+IRD ird = new IRD("./game.iso", "./game.getkey.log");
+```
+Finally, an existing IRD file can be read to create an IRD:
+ ```
+IRD ird = IRD.Read("./game.ird")
+```
+
+An IRD can be then be tweaked, its fields printed, and written to a new IRD:
+```
+ird.UID = 0x9F1A51D8;
+ird.Print();
+ird.Write("game2.ird");
+```