Start work on CLI tool
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
using LibIRD;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
|
||||
namespace BuildIRD
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
// Create new reproducible redump-style IRD with a key file
|
||||
try
|
||||
{
|
||||
// Read key from .key file
|
||||
byte[] discKey = File.ReadAllBytes("./game.key");
|
||||
|
||||
IRD ird1 = new ReIRD("./game.iso", discKey);
|
||||
ird1.Write("./test1.ird");
|
||||
ird1.Print();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine("ERROR: File not found");
|
||||
}
|
||||
|
||||
// Create new reproducible redump-style IRD with a ManaGunZ log
|
||||
try
|
||||
{
|
||||
IRD ird2 = new ReIRD("./game.iso", "./log.getkey.log");
|
||||
ird2.Write("./test2.ird");
|
||||
ird2.Print();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine("ERROR: File not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;linux-x64;osx-x64</RuntimeIdentifiers>
|
||||
<Version>0.1</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LibIRD\LibIRD.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<!-- Assembly Properties -->
|
||||
<OutputType>Exe</OutputType>
|
||||
<PackAsTool>true</PackAsTool>
|
||||
<ToolCommandName>irdkit</ToolCommandName>
|
||||
<PackageOutputPath>./nupkg</PackageOutputPath>
|
||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
||||
<RuntimeIdentifiers>win-x86;win-x64;win-arm64;linux-x64;linux-arm64;osx-x64;osx-arm64</RuntimeIdentifiers>
|
||||
<Version>0.1.0</Version>
|
||||
|
||||
<!-- Package Properties -->
|
||||
<Authors>Deterous</Authors>
|
||||
<Description>Library for ISO Rebuild Data</Description>
|
||||
<Copyright>Copyright (c) 2023 Deterous</Copyright>
|
||||
<!--<PackageReadmeFile>README.md</PackageReadmeFile>-->
|
||||
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>ps3 iso ird redump</PackageTags>
|
||||
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="./README.md" Pack="true" PackagePath=""/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\LibIRD\LibIRD.csproj" />
|
||||
<PackageReference Include="CommandLineParser" Version="2.9.1" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,113 @@
|
||||
using LibIRD;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommandLine;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
|
||||
namespace IRDKit
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
// IRD Creation
|
||||
[Verb("create")]
|
||||
public class CreateOptions
|
||||
{
|
||||
[Value(0, Required = true, HelpText = "Path to an ISO file, or directory of ISO files")]
|
||||
public string ISOPath { get; set; }
|
||||
|
||||
[Value(1, HelpText = "Path to the IRD file to be created")]
|
||||
public string IRDPath { get; set; }
|
||||
|
||||
[Option('r', "recurse", HelpText = "Recurse through all subdirectories and generate IRDs for all ISOs")]
|
||||
public bool Recurse { get; set; }
|
||||
|
||||
[Option('k', "key", HelpText = "Hexadecimal representation of the disc key")]
|
||||
public string Key { get; set; }
|
||||
|
||||
[Option("key-file", HelpText = "Path to a redump .key file")]
|
||||
public string KeyFile { get; set; }
|
||||
|
||||
[Option('l', "getkey-log", HelpText = "Path to a .getkey.log file")]
|
||||
public string GetKeyLog { get; set; }
|
||||
}
|
||||
|
||||
// IRD Info
|
||||
public class InfoOptions
|
||||
{
|
||||
[Value(0, Required = true, HelpText = "Path to the IRD file to be printed")]
|
||||
public string IRDPath { get; set; }
|
||||
}
|
||||
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
// Parse command line arguments
|
||||
var result = Parser.Default.ParseArguments<CreateOptions, InfoOptions>(args)
|
||||
.WithParsed(Run)
|
||||
.WithNotParsed(HandleParseError);
|
||||
}
|
||||
|
||||
private static void HandleParseError(IEnumerable<Error> errs)
|
||||
{
|
||||
if (errs.IsVersion())
|
||||
{
|
||||
// --version
|
||||
}
|
||||
else if (errs.IsHelp())
|
||||
{
|
||||
// --help
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parsing error
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
private static void Run(object obj)
|
||||
{
|
||||
switch (obj)
|
||||
{
|
||||
case CreateOptions c:
|
||||
Console.OutputEncoding = Encoding.UTF8;
|
||||
|
||||
// Create new reproducible redump-style IRD with a key file
|
||||
if (c.KeyFile != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Read key from .key file
|
||||
byte[] discKey = File.ReadAllBytes(c.KeyFile);
|
||||
|
||||
IRD ird1 = new ReIRD(c.ISOPath, discKey);
|
||||
ird1.Write(c.IRDPath);
|
||||
ird1.Print();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine("ERROR: File not found");
|
||||
}
|
||||
}
|
||||
|
||||
// Create new reproducible redump-style IRD with a GetKey log
|
||||
if (c.GetKeyLog != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
IRD ird2 = new ReIRD(c.ISOPath, c.GetKeyLog);
|
||||
ird2.Write(c.IRDPath);
|
||||
ird2.Print();
|
||||
}
|
||||
catch (FileNotFoundException)
|
||||
{
|
||||
Console.WriteLine("ERROR: File not found");
|
||||
}
|
||||
}
|
||||
break;
|
||||
case InfoOptions info:
|
||||
//
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
## How to use IRDKit
|
||||
|
||||
IRDKit is a tool that allows direct use of LibIRD functionality from the command line interface. The basic usage is:
|
||||
```
|
||||
irdkit game.iso game.ird
|
||||
```
|
||||
For detailed usage, run `irdkit --help`
|
||||
+6
-6
@@ -5,9 +5,9 @@ VisualStudioVersion = 17.7.34202.233
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LibIRD", "LibIRD\LibIRD.csproj", "{4A80C34B-D4C5-4536-BEAE-46218BC09980}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BuildIRD", "BuildIRD\BuildIRD.csproj", "{A2FC2D93-1C3E-46E2-9D69-11F9DDA8CFC7}"
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PrintParams", "PrintParams\PrintParams.csproj", "{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PrintParams", "PrintParams\PrintParams.csproj", "{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IRDKit", "IRDKit\IRDKit.csproj", "{9060E3AF-E4FB-436F-93A1-5C47389CB88E}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
@@ -19,14 +19,14 @@ Global
|
||||
{4A80C34B-D4C5-4536-BEAE-46218BC09980}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A80C34B-D4C5-4536-BEAE-46218BC09980}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A80C34B-D4C5-4536-BEAE-46218BC09980}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A2FC2D93-1C3E-46E2-9D69-11F9DDA8CFC7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A2FC2D93-1C3E-46E2-9D69-11F9DDA8CFC7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A2FC2D93-1C3E-46E2-9D69-11F9DDA8CFC7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A2FC2D93-1C3E-46E2-9D69-11F9DDA8CFC7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B5D9C0AD-EA8D-486E-A1D7-ED2C3C7163BC}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{9060E3AF-E4FB-436F-93A1-5C47389CB88E}.Debug|Any CPU.ActiveCfg = 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.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
||||
+1
-1
@@ -1285,7 +1285,7 @@ namespace LibIRD
|
||||
print.AppendLine("=============");
|
||||
|
||||
// Append IRD fields to string builder
|
||||
print.AppendLine($"Magic: 3IRD");
|
||||
print.AppendLine($"Magic: {Encoding.ASCII.GetString(Magic)}");
|
||||
print.AppendLine($"IRD Version: {Version}");
|
||||
print.AppendLine($"Title ID: {TitleID}");
|
||||
print.AppendLine($"Title: {Title}");
|
||||
|
||||
@@ -9,16 +9,16 @@
|
||||
<!-- Package Properties -->
|
||||
<Authors>Deterous</Authors>
|
||||
<Description>Library for ISO Rebuild Data</Description>
|
||||
<Copyright>Copyright (c) Deterous 2023</Copyright>
|
||||
<Copyright>Copyright (c) 2023 Deterous</Copyright>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<RepositoryUrl>https://github.com/Deterous/LibIRD</RepositoryUrl>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<PackageTags>ps3 iso ird</PackageTags>
|
||||
<PackageTags>ps3 iso ird redump</PackageTags>
|
||||
<PackageLicenseExpression>GPL-3.0-only</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="../README.md" Pack="true" PackagePath=""/>
|
||||
<None Include="./README.md" Pack="true" PackagePath=""/>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -100,6 +100,10 @@ namespace LibIRD
|
||||
get
|
||||
{
|
||||
int index = Array.FindIndex(Params, param => param.Name == key);
|
||||
if (index == -1)
|
||||
return null;
|
||||
if (Params[index].DataFormat == 0x0404)
|
||||
return Params[index].IntValue.ToString();
|
||||
return Params[index].StringValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
## How to use the LibIRD library
|
||||
|
||||
LibIRD was originally made for creating reproducible, redump-style IRDs when dumping PS3 discs with [MPF](https://github.com/SabreTools/MPF). If you wish to integrate LibIRD into your own application, the following are some examples.
|
||||
|
||||
### Reproducible, redump-style IRDs
|
||||
|
||||
The standard way of generating a reproducible, redump-style IRD is with a redump ISO file and a redump key file (e.g. http://redump.org/disc/28721/key/):
|
||||
```cs
|
||||
byte[] discKey = File.ReadAllBytes("./game.key");
|
||||
IRD ird = new ReIRD("./game.iso", discKey);
|
||||
```
|
||||
Alternatively, the disc key can be extracted from a [GetKey](https://archive.org/download/GetKeyR2GameOS.7z/GetKey-r2-GameOS.7z) log file obtained from a PS3 (or when dumping using [ManaGunZ](https://github.com/Zarh/ManaGunZ/))
|
||||
```cs
|
||||
IRD ird = new ReIRD("./game.iso", "./game.getkey.log");
|
||||
```
|
||||
|
||||
### Custom IRDs
|
||||
|
||||
Functionality is also provided for creating IRDs with a custom disc key, disc ID, and PIC:
|
||||
```cs
|
||||
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 GetKey log file can also be used with an ISO to create a custom IRD, with the disc key, disc ID, and PIC all being extracted from the log file (rather than just the key for redump-style IRDs).
|
||||
```cs
|
||||
IRD ird = new IRD("./game.iso", "./game.getkey.log");
|
||||
```
|
||||
Finally, an existing IRD file can be read to create an IRD:
|
||||
```cs
|
||||
IRD ird = IRD.Read("./game.ird")
|
||||
```
|
||||
An IRD can be then be tweaked, its fields printed, and written to a new IRD:
|
||||
```cs
|
||||
ird.UID = 0x9F1A51D8;
|
||||
ird.Print();
|
||||
ird.Write("game2.ird");
|
||||
```
|
||||
@@ -2,42 +2,18 @@
|
||||
|
||||
.NET library 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 IRD file.
|
||||
|
||||
## How to use LibIRD
|
||||
## What is an IRD?
|
||||
|
||||
### Reproducible, redump-style IRDs
|
||||
IRD files contain a summary of what data is on a PlayStation 3 disc. It can be used to rebuild ISOs from files (JB folders). IRD files are also useful for decrypting ISOs after they have been dumped on a PC blu-ray drive, such as for the purposes of legally emulating your PS3 games.
|
||||
|
||||
The standard way of generating a reproducible, redump-style IRD is with a redump ISO file and a redump key file (e.g. http://redump.org/disc/28721/key/):
|
||||
```cs
|
||||
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/) log file:
|
||||
```cs
|
||||
IRD ird = new ReIRD("./game.iso", "./game.getkey.log");
|
||||
```
|
||||
## How to use IRDKit
|
||||
|
||||
### Custom IRDs
|
||||
IRDKit is a tool that allows direct use of LibIRD functionality from the command line interface. The basic usage is:
|
||||
```
|
||||
irdkit create game.iso
|
||||
```
|
||||
For detailed usage, read more [here](IRDKit/README.MD).
|
||||
|
||||
Functionality is also provided for creating IRDs with a custom disc key, disc ID, and PIC:
|
||||
```cs
|
||||
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 a custom IRD, with the disc key, disc ID, and PIC all being extracted from the log file (rather than just the key).
|
||||
```cs
|
||||
IRD ird = new IRD("./game.iso", "./game.getkey.log");
|
||||
```
|
||||
Finally, an existing IRD file can be read to create an IRD:
|
||||
```cs
|
||||
IRD ird = IRD.Read("./game.ird")
|
||||
```
|
||||
## Using the LibIRD library
|
||||
|
||||
An IRD can be then be tweaked, its fields printed, and written to a new IRD:
|
||||
```cs
|
||||
ird.UID = 0x9F1A51D8;
|
||||
ird.Print();
|
||||
ird.Write("game2.ird");
|
||||
```
|
||||
LibIRD was originally made for creating reproducible, redump-style IRDs when dumping PS3 discs with [MPF](https://github.com/SabreTools/MPF). If you wish to integrate LibIRD into your own application, read the examples [here](LibIRD/README.MD).
|
||||
|
||||
Reference in New Issue
Block a user