Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ab6a9d694 | ||
|
|
bc3df52e75 |
+1
-1
Submodule DiscUtils updated: a99992e5f4...299030c20b
@@ -9,7 +9,7 @@
|
|||||||
<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>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>0.4.0</Version>
|
<Version>0.4.1</Version>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
<Authors>Deterous</Authors>
|
<Authors>Deterous</Authors>
|
||||||
|
|||||||
@@ -610,7 +610,9 @@ namespace IRDKit
|
|||||||
missingOffsets1.Add(IRD2.FileKeys[i]);
|
missingOffsets1.Add(IRD2.FileKeys[i]);
|
||||||
}
|
}
|
||||||
// Print the file offsets that differ
|
// Print the file offsets that differ
|
||||||
|
if (missingOffsets1.Count > 0)
|
||||||
printText.AppendLine($"File Offsets not Present in {irdPath1}: {string.Join(", ", missingOffsets1)}");
|
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)}");
|
printText.AppendLine($"File Offsets not Present in {irdPath2}: {string.Join(", ", missingOffsets2)}");
|
||||||
|
|
||||||
// Print any extra config data difference
|
// Print any extra config data difference
|
||||||
|
|||||||
+6
-7
@@ -946,23 +946,22 @@ namespace LibIRD
|
|||||||
if (fileClusters[i].Offset < smallestOffset)
|
if (fileClusters[i].Offset < smallestOffset)
|
||||||
smallestOffset = fileClusters[i].Offset;
|
smallestOffset = fileClusters[i].Offset;
|
||||||
}
|
}
|
||||||
int firstSector = (int)(smallestOffset);
|
|
||||||
|
|
||||||
// If already encountered file offset, skip this file
|
// If already encountered file offset, skip this file
|
||||||
if (Array.Exists(FileKeys, element => element == firstSector))
|
if (Array.Exists(FileKeys, element => element == smallestOffset))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (fileClusters.Length > 1)
|
if (fileClusters.Length > 1)
|
||||||
Console.WriteLine($"Split file detected: {filePath}");
|
Console.WriteLine($"Split file detected: {filePath}");
|
||||||
|
|
||||||
// Add file offset to keys
|
// Add file offset to keys
|
||||||
FileKeys[FileCount] = firstSector;
|
FileKeys[FileCount] = smallestOffset;
|
||||||
|
|
||||||
// Determine whether file is in encrypted or decrypted region
|
// Determine whether file is in encrypted or decrypted region
|
||||||
bool encrypted = false;
|
bool encrypted = false;
|
||||||
for (int i = RegionCount - 1; i > 0; i--)
|
for (int i = RegionCount - 1; i > 0; i--)
|
||||||
{
|
{
|
||||||
if (RegionStart[i] <= firstSector)
|
if (RegionStart[i] <= smallestOffset)
|
||||||
{
|
{
|
||||||
encrypted = i % 2 == 1;
|
encrypted = i % 2 == 1;
|
||||||
break;
|
break;
|
||||||
@@ -986,7 +985,7 @@ namespace LibIRD
|
|||||||
throw new InvalidFileSystemException("Disc region ended unexpectedly");
|
throw new InvalidFileSystemException("Disc region ended unexpectedly");
|
||||||
// Decrypt sector if necessary
|
// Decrypt sector if necessary
|
||||||
if (encrypted)
|
if (encrypted)
|
||||||
buf = DecryptSector(buf, firstSector + j);
|
buf = DecryptSector(buf, (int)fileClusters[i].Offset + j);
|
||||||
// Hash sector
|
// Hash sector
|
||||||
md5.TransformBlock(buf, 0, numBytes, null, 0);
|
md5.TransformBlock(buf, 0, numBytes, null, 0);
|
||||||
}
|
}
|
||||||
@@ -999,7 +998,7 @@ namespace LibIRD
|
|||||||
throw new InvalidFileSystemException("Disc region ended unexpectedly");
|
throw new InvalidFileSystemException("Disc region ended unexpectedly");
|
||||||
// Decrypt partial sector if necessary
|
// Decrypt partial sector if necessary
|
||||||
if (encrypted)
|
if (encrypted)
|
||||||
buf = DecryptSector(buf, firstSector + (int)(fileClusters[i].Count / SectorSize));
|
buf = DecryptSector(buf, (int)fileClusters[i].Offset + (int)(fileClusters[i].Count / SectorSize));
|
||||||
// Hash partial sector
|
// Hash partial sector
|
||||||
md5.TransformBlock(buf, 0, (int)(fileClusters[i].Count % SectorSize), null, 0);
|
md5.TransformBlock(buf, 0, (int)(fileClusters[i].Count % SectorSize), null, 0);
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1063,7 @@ namespace LibIRD
|
|||||||
CountFiles(dirInfo);
|
CountFiles(dirInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IRD File
|
#region IRD File
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<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>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||||
<Version>0.4.0</Version>
|
<Version>0.4.1</Version>
|
||||||
<PackageOutputPath>../nupkg</PackageOutputPath>
|
<PackageOutputPath>../nupkg</PackageOutputPath>
|
||||||
|
|
||||||
<!-- Package Properties -->
|
<!-- Package Properties -->
|
||||||
|
|||||||
@@ -131,6 +131,11 @@ namespace LibIRD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Define JSON options once
|
||||||
|
/// </summary>
|
||||||
|
private readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints parameters extracted from PS3_DISC.SFB to a json object
|
/// Prints parameters extracted from PS3_DISC.SFB to a json object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -138,7 +143,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 = JsonSerializer.Serialize(Field, JsonOpts);
|
||||||
|
|
||||||
// If no path given, output to console
|
// If no path given, output to console
|
||||||
if (jsonPath == null)
|
if (jsonPath == null)
|
||||||
|
|||||||
+10
-5
@@ -103,7 +103,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 +112,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'),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -159,6 +159,11 @@ namespace LibIRD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Define JSON options once
|
||||||
|
/// </summary>
|
||||||
|
private readonly JsonSerializerOptions JsonOpts = new() { WriteIndented = true };
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints parameters extracted from PARAM.SFO to a json object
|
/// Prints parameters extracted from PARAM.SFO to a json object
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -166,7 +171,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 = JsonSerializer.Serialize(Field, JsonOpts);
|
||||||
|
|
||||||
// If no path given, output to console
|
// If no path given, output to console
|
||||||
if (jsonPath == null)
|
if (jsonPath == null)
|
||||||
|
|||||||
+1
-2
@@ -2,7 +2,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Hashing;
|
using System.IO.Hashing;
|
||||||
using System.Security;
|
|
||||||
|
|
||||||
namespace LibIRD
|
namespace LibIRD
|
||||||
{
|
{
|
||||||
@@ -172,7 +171,7 @@ namespace LibIRD
|
|||||||
|
|
||||||
// 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 = [
|
||||||
|
|||||||
Reference in New Issue
Block a user