Skip to content

Commit

Permalink
Merge pull request #51 from zzpong/master
Browse files Browse the repository at this point in the history
master_key_0a supported, fix issue #50 and more
  • Loading branch information
StudentBlake authored Mar 8, 2020
2 parents 72fc846 + 24fab83 commit c854cd4
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("XCI Explorer")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("206c6c47-87b1-477f-b6e6-f7e7c1a92f8f")]
[assembly: AssemblyFileVersion("1.4.9")]
[assembly: AssemblyVersion("1.4.9")]
[assembly: AssemblyFileVersion("1.5.0")]
[assembly: AssemblyVersion("1.5.0")]
2 changes: 1 addition & 1 deletion XCI Explorer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<OutputType>WinExe</OutputType>
<AssemblyName>XCI-Explorer</AssemblyName>
<TargetFrameworkIdentifier>.NETFramework</TargetFrameworkIdentifier>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<NuGetPackageImportStamp>
Expand Down
63 changes: 45 additions & 18 deletions XCI_Explorer/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public MainForm()
{
using (var client = new WebClient())
{
client.DownloadFile(Util.Base64Decode("aHR0cHM6Ly9wYXN0ZWJpbi5jb20vcmF3L3dZbUxUTkxx"), "keys.txt");
client.DownloadFile(Util.Base64Decode("aHR0cHM6Ly9wYXN0ZWJpbi5jb20vcmF3L2NWR3JQSHp6"), "keys.txt");
}
}

Expand Down Expand Up @@ -124,19 +124,26 @@ select x.Split('=') into x
where x.Length > 1
select x).ToDictionary((string[] x) => x[0].Trim(), (string[] x) => x[1]);
Mkey = "master_key_";
string MkeyL = "master_key_";
if (NCA.NCA_Headers[0].MasterKeyRev == 0 || NCA.NCA_Headers[0].MasterKeyRev == 1)
{
Mkey += "00";
}
else if (NCA.NCA_Headers[0].MasterKeyRev < 17)
{
int num = NCA.NCA_Headers[0].MasterKeyRev - 1;
Mkey = Mkey + "0" + num.ToString();
string capchar = num.ToString("X");
string lowchar = capchar.ToLower();
Mkey = Mkey + "0" + capchar;
MkeyL = MkeyL + "0" + lowchar;
}
else if (NCA.NCA_Headers[0].MasterKeyRev >= 17)
{
int num2 = NCA.NCA_Headers[0].MasterKeyRev - 1;
string capchar = num2.ToString("X");
string lowchar = capchar.ToLower();
Mkey += num2.ToString();
MkeyL += num2.ToString();
}
try
{
Expand All @@ -145,7 +152,15 @@ where x.Length > 1
}
catch
{
return false;
try
{
MkeyL = dictionary[MkeyL].Replace(" ", "");
return true;
}
catch
{
return false;
}
}
}

Expand Down Expand Up @@ -188,11 +203,11 @@ private void ProcessFile()
MessageBox.Show("File is corrupt or unsupported.");
}
}
catch(Exception e)
catch (Exception e)
{
MessageBox.Show("Error: " + e.ToString() + "\nFile is corrupt or unsupported.");
}

}

private void B_LoadROM_Click(object sender, EventArgs e)
Expand Down Expand Up @@ -634,26 +649,44 @@ public void LoadNSP()
else if (strArray[0] == "Master Key Revision")
{
string MasterKey = strArray[1].Trim();
int keyblob;

if (MasterKey.Contains("Unknown"))
{
int keyblob;
if (int.TryParse(new string(MasterKey.TakeWhile(Char.IsDigit).ToArray()), out keyblob))
{
MasterKey = Util.GetMkey((byte)(keyblob + 1)).Replace("MasterKey", "");
}
TB_MKeyRev.Text = "MasterKey" + MasterKey;
}
TB_MKeyRev.Text = "MasterKey" + MasterKey;
else
{
MasterKey = MasterKey.Split(new char[2] { 'x', ' ' })[1];
keyblob = Convert.ToInt32(MasterKey, 16);
MasterKey = Util.GetMkey((byte)(keyblob + 1));
TB_MKeyRev.Text = MasterKey;
}

break;
}
}
process.WaitForExit();
process.Close();
}
catch { }
if (Directory.Exists("tmp"))

try
{
File.Delete("meta");
Directory.Delete("data", true);
}
catch { }

try
{
Directory.Delete("tmp", true);
}
catch { }

TB_Capacity.Text = "eShop";

Expand Down Expand Up @@ -684,15 +717,12 @@ private void LoadGameInfos()

if (SecureName[si].EndsWith(".cnmt.nca"))
{
if (File.Exists("meta"))
try
{
File.Delete("meta");
}

if (Directory.Exists("data"))
{
Directory.Delete("data", true);
}
catch { }

using (FileStream fileStream2 = File.OpenWrite("meta"))
{
Expand Down Expand Up @@ -755,15 +785,12 @@ private void LoadGameInfos()

if (ncaTarget.Contains(SecureName[si]))
{
if (File.Exists("meta"))
try
{
File.Delete("meta");
}

if (Directory.Exists("data"))
{
Directory.Delete("data", true);
}
catch { }

using (FileStream fileStream2 = File.OpenWrite("meta"))
{
Expand Down
4 changes: 3 additions & 1 deletion XCI_Explorer/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public static string GetCapacity(int id)
{
switch (id)
{
case 250:
return "1GB";
case 248:
return "2GB";
case 240:
Expand Down Expand Up @@ -51,7 +53,7 @@ public static string GetMkey(byte id)
case 10:
return "MasterKey9 (9.0.0-9.0.1)";
case 11:
return "MasterKey10 (?)";
return "MasterKey10 (9.1.0-9.2.0)";
case 12:
return "MasterKey11 (?)";
case 13:
Expand Down
2 changes: 1 addition & 1 deletion app.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/></startup></configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/></startup></configuration>

0 comments on commit c854cd4

Please sign in to comment.