mirror of
https://github.com/SabreTools/NDecrypt.git
synced 2026-09-22 14:55:03 +00:00
Add simple info check (fixes #18)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Models.Nitro;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
@@ -590,8 +591,37 @@ namespace NDecrypt.Core
|
||||
/// <inheritdoc/>
|
||||
public string? GetInformation(string filename)
|
||||
{
|
||||
// TODO: Get decryption status
|
||||
return null;
|
||||
try
|
||||
{
|
||||
// Open the file for reading
|
||||
using var input = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
// Deserialize the cart information
|
||||
var cart = Nitro.Create(input);
|
||||
if (cart?.Model == null)
|
||||
return "Error: Not a DS or DSi Rom!";
|
||||
|
||||
// Get a string builder for the status
|
||||
var sb = new StringBuilder();
|
||||
sb.Append("Secure Area: ");
|
||||
|
||||
// Get the encryption status
|
||||
bool? decrypted = CheckIfDecrypted(input);
|
||||
if (decrypted == null)
|
||||
sb.Append("Empty");
|
||||
else if (decrypted == true)
|
||||
sb.Append("Decrypted");
|
||||
else
|
||||
sb.Append("English");
|
||||
|
||||
// Return the status for the secure area
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using SabreTools.IO.Extensions;
|
||||
using SabreTools.Models.N3DS;
|
||||
using SabreTools.Serialization.Wrappers;
|
||||
@@ -871,14 +872,40 @@ namespace NDecrypt.Core
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region Info
|
||||
|
||||
/// <inheritdoc/>
|
||||
public string? GetInformation(string filename)
|
||||
{
|
||||
// TODO: Get decryption status
|
||||
return null;
|
||||
try
|
||||
{
|
||||
// Open the file for reading
|
||||
using var input = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
|
||||
|
||||
// Deserialize the cart information
|
||||
var cart = N3DS.Create(input);
|
||||
if (cart?.Model == null)
|
||||
return "Error: Not a 3DS cart image!";
|
||||
|
||||
// Get a string builder for the status
|
||||
var sb = new StringBuilder();
|
||||
|
||||
// Iterate over all 8 NCCH partitions
|
||||
for (int p = 0; p < 8; p++)
|
||||
{
|
||||
bool decrypted = cart.PossiblyDecrypted(p);
|
||||
sb.AppendLine($"Partition {p}: {(decrypted ? "Decrypted" : "Encrypted")}");
|
||||
}
|
||||
|
||||
// Return the status for all partitions
|
||||
return sb.ToString();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user