Print IRD fields, add a READEME

This commit is contained in:
Deterous
2023-11-10 22:09:00 +13:00
parent b9fd217fbf
commit 2fcf5fcae3
6 changed files with 93 additions and 28 deletions
+5 -23
View File
@@ -19,41 +19,23 @@ namespace BuildIRD
IRD ird1 = new ReIRD("./game.iso", discKey); IRD ird1 = new ReIRD("./game.iso", discKey);
ird1.Write("./test1.ird"); ird1.Write("./test1.ird");
Console.WriteLine("IRD created using .key:"); ird1.Print();
// 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);
} }
catch (FileNotFoundException e) 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 try
{ {
IRD ird2 = new ReIRD("./game.iso", "./log.getkey.log"); IRD ird2 = new ReIRD("./game.iso", "./log.getkey.log");
ird2.Write("./test2.ird"); ird2.Write("./test2.ird");
Console.WriteLine("IRD created using .getkey.log:"); ird2.Print();
// 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);
} }
catch (FileNotFoundException e) catch (FileNotFoundException e)
{ {
Console.WriteLine("File not found: " + e.FileName); Console.WriteLine("ERROR: File not found");
} }
} }
} }
+37
View File
@@ -1242,6 +1242,43 @@ namespace LibIRD
uid); uid);
} }
/// <summary>
/// Prints IRD fields to console
/// </summary>
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 #endregion
} }
} }
+2 -1
View File
@@ -9,7 +9,8 @@
<!-- Package Properties --> <!-- Package Properties -->
<Authors>Deterous</Authors> <Authors>Deterous</Authors>
<Description>Library for ISO Rebuild Data</Description> <Description>Library for ISO Rebuild Data</Description>
<Copyright>Copyright (c)2023 Deterous</Copyright> <Copyright>Copyright (c) Deterous 2023</Copyright>
<PackageReadmeFile>README.MD</PackageReadmeFile>
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl> <RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<PackageTags>ps3 iso ird</PackageTags> <PackageTags>ps3 iso ird</PackageTags>
+5 -2
View File
@@ -208,7 +208,9 @@ namespace LibIRD
public void Print() public void Print()
{ {
// Build string from parameters // 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 // Loop through all parameters in PARAM.SFO
for (int i = 0; i < ParamCount; i++) for (int i = 0; i < ParamCount; i++)
@@ -221,9 +223,10 @@ namespace LibIRD
{ {
case 0x0404: case 0x0404:
print.Append(Params[i].IntValue); print.Append(Params[i].IntValue);
print.AppendLine();
break; break;
default: default:
print.Append(Params[i].StringValue); print.AppendLine(Params[i].StringValue);
break; break;
} }
print.Append('\n'); print.Append('\n');
+1 -1
View File
@@ -56,7 +56,7 @@ namespace LibIRD
/// <summary> /// <summary>
/// ISO file size /// ISO file size
/// </summary> /// </summary>
public long Size { get; private set; } private long Size { get; set; }
#endregion #endregion
+43 -1
View File
@@ -1 +1,43 @@
# WIP # 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");
```