mirror of
https://github.com/WiiDatabase/nusdownloader.git
synced 2024-12-25 01:51:50 +01:00
Improvements on content mananger. It is now able to not error out (most of the time), so debugging can now commence :|
This commit is contained in:
parent
ab6575995f
commit
3f5ed5e03a
13
NUS Downloader/Form1.Designer.cs
generated
13
NUS Downloader/Form1.Designer.cs
generated
@ -91,7 +91,6 @@
|
|||||||
this.button5 = new System.Windows.Forms.Button();
|
this.button5 = new System.Windows.Forms.Button();
|
||||||
this.button6 = new System.Windows.Forms.Button();
|
this.button6 = new System.Windows.Forms.Button();
|
||||||
this.button7 = new System.Windows.Forms.Button();
|
this.button7 = new System.Windows.Forms.Button();
|
||||||
this.label12 = new System.Windows.Forms.Label();
|
|
||||||
this.shamelessvariablelabel = new System.Windows.Forms.Label();
|
this.shamelessvariablelabel = new System.Windows.Forms.Label();
|
||||||
this.button3 = new System.Windows.Forms.Button();
|
this.button3 = new System.Windows.Forms.Button();
|
||||||
this.contentsEdit = new System.Windows.Forms.ListBox();
|
this.contentsEdit = new System.Windows.Forms.ListBox();
|
||||||
@ -695,16 +694,6 @@
|
|||||||
this.button7.UseVisualStyleBackColor = true;
|
this.button7.UseVisualStyleBackColor = true;
|
||||||
this.button7.Click += new System.EventHandler(this.button7_Click);
|
this.button7.Click += new System.EventHandler(this.button7_Click);
|
||||||
//
|
//
|
||||||
// label12
|
|
||||||
//
|
|
||||||
this.label12.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
|
||||||
this.label12.Location = new System.Drawing.Point(239, 465);
|
|
||||||
this.label12.Name = "label12";
|
|
||||||
this.label12.Size = new System.Drawing.Size(23, 15);
|
|
||||||
this.label12.TabIndex = 29;
|
|
||||||
this.label12.Text = resources.GetString("label12.Text");
|
|
||||||
this.label12.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
|
||||||
//
|
|
||||||
// shamelessvariablelabel
|
// shamelessvariablelabel
|
||||||
//
|
//
|
||||||
this.shamelessvariablelabel.AutoSize = true;
|
this.shamelessvariablelabel.AutoSize = true;
|
||||||
@ -896,7 +885,6 @@
|
|||||||
this.Controls.Add(this.button17);
|
this.Controls.Add(this.button17);
|
||||||
this.Controls.Add(this.button3);
|
this.Controls.Add(this.button3);
|
||||||
this.Controls.Add(this.shamelessvariablelabel);
|
this.Controls.Add(this.shamelessvariablelabel);
|
||||||
this.Controls.Add(this.label12);
|
|
||||||
this.Controls.Add(this.button1);
|
this.Controls.Add(this.button1);
|
||||||
this.Controls.Add(this.ticketgpbox);
|
this.Controls.Add(this.ticketgpbox);
|
||||||
this.Controls.Add(this.button5);
|
this.Controls.Add(this.button5);
|
||||||
@ -1007,7 +995,6 @@
|
|||||||
private System.Windows.Forms.TextBox timelimitsecs;
|
private System.Windows.Forms.TextBox timelimitsecs;
|
||||||
private System.Windows.Forms.Label label11;
|
private System.Windows.Forms.Label label11;
|
||||||
private System.Windows.Forms.Button button7;
|
private System.Windows.Forms.Button button7;
|
||||||
private System.Windows.Forms.Label label12;
|
|
||||||
private System.Windows.Forms.Label shamelessvariablelabel;
|
private System.Windows.Forms.Label shamelessvariablelabel;
|
||||||
private System.Windows.Forms.Button button3;
|
private System.Windows.Forms.Button button3;
|
||||||
private System.Windows.Forms.ListBox contentsEdit;
|
private System.Windows.Forms.ListBox contentsEdit;
|
||||||
|
@ -2287,7 +2287,7 @@ namespace NUS_Downloader
|
|||||||
private void button8_Click(object sender, EventArgs e)
|
private void button8_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Move selected content upwards (down an index)...
|
// Move selected content upwards (down an index)...
|
||||||
if (contentsEdit.SelectedIndex < 0)
|
if (contentsEdit.SelectedIndex <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int sel_idx = contentsEdit.SelectedIndex;
|
int sel_idx = contentsEdit.SelectedIndex;
|
||||||
@ -2465,7 +2465,7 @@ namespace NUS_Downloader
|
|||||||
contents[c].Type[0] = 0x00;
|
contents[c].Type[0] = 0x00;
|
||||||
|
|
||||||
// Pad to be 16 byte aligned
|
// Pad to be 16 byte aligned
|
||||||
contentbytes = AlignByteArray(contentbytes, 16);
|
contentbytes = PadToMultipleOf(contentbytes, 16);
|
||||||
|
|
||||||
// Encrypt with correct index IV/titlekey
|
// Encrypt with correct index IV/titlekey
|
||||||
byte[] ivindex = new byte[16];
|
byte[] ivindex = new byte[16];
|
||||||
@ -2526,15 +2526,16 @@ namespace NUS_Downloader
|
|||||||
}
|
}
|
||||||
|
|
||||||
byte[] decContent = Decrypt(contentbytes);
|
byte[] decContent = Decrypt(contentbytes);
|
||||||
Array.Resize(ref decContent, int.Parse(tmdsizes[c], System.Globalization.NumberStyles.HexNumber));
|
Array.Resize(ref decContent, int.Parse(tmdsizes[thiscontentidx], System.Globalization.NumberStyles.HexNumber));
|
||||||
if ((Convert.ToBase64String(ComputeSHA(decContent))) == Convert.ToBase64String(hash))
|
if ((Convert.ToBase64String(ComputeSHA(decContent))) == Convert.ToBase64String(hash))
|
||||||
{
|
{
|
||||||
WriteStatus(" - Hash Check: Content is Unchanged...");
|
WriteStatus(" - Hash Check: Content is Unchanged...");
|
||||||
contents[c].SHAHash = hash;
|
contents[c].SHAHash = hash;
|
||||||
|
WriteStatus("HASH: " + DisplayBytes(hash, ""));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WriteStatus(" - Hash Check: Content changed (probably REALLY BAD)...");
|
WriteStatus(" - Hash Check: Content changed (probably REALLY BAD)...");
|
||||||
contents[c].SHAHash = ComputeSHA(decContent);
|
contents[c].SHAHash = ComputeSHA(decContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2549,7 +2550,8 @@ namespace NUS_Downloader
|
|||||||
ivindex[1] = (byte)c;
|
ivindex[1] = (byte)c;
|
||||||
|
|
||||||
// Pad back to 0x16 alignment
|
// Pad back to 0x16 alignment
|
||||||
AlignByteArray(decContent, 0x16);
|
//AlignByteArray(decContent, 0x16
|
||||||
|
decContent = PadToMultipleOf(decContent, 16);
|
||||||
|
|
||||||
initCrypt(newiv, dtitlekey);
|
initCrypt(newiv, dtitlekey);
|
||||||
|
|
||||||
@ -2576,10 +2578,10 @@ namespace NUS_Downloader
|
|||||||
contents[c].ContentID[3] = byte.Parse(filename.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
|
contents[c].ContentID[3] = byte.Parse(filename.Substring(6, 2), System.Globalization.NumberStyles.HexNumber);
|
||||||
|
|
||||||
contents[c].Index = new byte[2];
|
contents[c].Index = new byte[2];
|
||||||
contents[c].Index = InttoByteArray(c, 2); // TODOTODOTODO
|
contents[c].Index = NewIntegertoByteArray(c, 2);
|
||||||
|
|
||||||
contents[c].Type = new byte[2];
|
contents[c].Type = new byte[2];
|
||||||
contents[c].Type[0] = 0x01;
|
contents[c].Type[1] = 0x01;
|
||||||
if (contentsEdit.Items[c].ToString().Contains(" [S]"))
|
if (contentsEdit.Items[c].ToString().Contains(" [S]"))
|
||||||
contents[c].Type[0] = 0x80;
|
contents[c].Type[0] = 0x80;
|
||||||
else
|
else
|
||||||
@ -2587,12 +2589,13 @@ namespace NUS_Downloader
|
|||||||
|
|
||||||
contents[c].Size = new byte[8];
|
contents[c].Size = new byte[8];
|
||||||
// TODOCHECK THIS OVER
|
// TODOCHECK THIS OVER
|
||||||
contents[c].Size = InttoByteArray(contentbytes.Length, 8);
|
contents[c].Size = NewIntegertoByteArray(contentbytes.Length, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
// Write all this stuff to the TMD...
|
// Write all this stuff to the TMD...
|
||||||
byte[] contentSection = new byte[contents.Length * 36];
|
byte[] contentSection = new byte[contents.Length * 36];
|
||||||
|
//TODO: At some points we don't have a hash... see above?
|
||||||
for (int h = 0; h < contents.Length; h++)
|
for (int h = 0; h < contents.Length; h++)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < contents[h].ContentID.Length; i++)
|
for (int i = 0; i < contents[h].ContentID.Length; i++)
|
||||||
@ -2612,12 +2615,12 @@ namespace NUS_Downloader
|
|||||||
|
|
||||||
for (int l = 0; l < contents[h].Size.Length; l++)
|
for (int l = 0; l < contents[h].Size.Length; l++)
|
||||||
{
|
{
|
||||||
contentSection[(h * 36) + (contents[h].ContentID.Length + contents[h].Index.Length + contents[h].Type.Length + l)] = contents[h].Type[l];
|
contentSection[(h * 36) + (contents[h].ContentID.Length + contents[h].Index.Length + contents[h].Type.Length + l)] = contents[h].Size[l];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int m = 0; m < contents[h].SHAHash.Length; m++)
|
for (int m = 0; m < contents[h].SHAHash.Length; m++)
|
||||||
{
|
{
|
||||||
contentSection[(h * 36) + (contents[h].ContentID.Length + contents[h].Index.Length + contents[h].Type.Length + contents[h].Size.Length + m)] = contents[h].Type[m];
|
contentSection[(h * 36) + (contents[h].ContentID.Length + contents[h].Index.Length + contents[h].Type.Length + contents[h].Size.Length + m)] = contents[h].SHAHash[m];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2633,30 +2636,46 @@ namespace NUS_Downloader
|
|||||||
FileStream testtmd = new FileStream(fileinfo[0] + fileinfo[1], FileMode.Open);
|
FileStream testtmd = new FileStream(fileinfo[0] + fileinfo[1], FileMode.Open);
|
||||||
testtmd.Write(tmd, 0, tmd.Length);
|
testtmd.Write(tmd, 0, tmd.Length);
|
||||||
testtmd.Close();
|
testtmd.Close();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pad Byte[] to specific alignment...
|
/* Pad Byte[] to specific alignment...
|
||||||
private byte[] AlignByteArray(byte[] content, int alignto)
|
private byte[] AlignByteArray(byte[] content, int alignto)
|
||||||
{
|
{
|
||||||
long thelength = content.Length - 1;
|
long thelength = content.Length - 1;
|
||||||
long remainder = 1;
|
long remainder = thelength % alignto;
|
||||||
|
|
||||||
while (remainder != 0)
|
while (remainder != 0)
|
||||||
{
|
{
|
||||||
thelength += 1;
|
thelength += 1;
|
||||||
remainder = thelength % alignto;
|
remainder = thelength % alignto;
|
||||||
}
|
}
|
||||||
|
// DEBUG:
|
||||||
|
WriteStatus("Aligning by: " + alignto + " ... New Length: " + thelength);
|
||||||
|
WriteStatus(" Dif: " + (thelength - content.Length));
|
||||||
Array.Resize(ref content, (int)thelength);
|
Array.Resize(ref content, (int)thelength);
|
||||||
return content;
|
return content;
|
||||||
|
} */
|
||||||
|
|
||||||
|
private byte[] PadToMultipleOf(byte[] src, int pad)
|
||||||
|
{
|
||||||
|
int len = (src.Length + pad - 1) / pad * pad;
|
||||||
|
|
||||||
|
// DEBUG:
|
||||||
|
WriteStatus("New Length: " + len);
|
||||||
|
WriteStatus("Dif: " + (len - src.Length));
|
||||||
|
|
||||||
|
Array.Resize(ref src, len);
|
||||||
|
return src;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void button17_Click(object sender, EventArgs e)
|
private void button17_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
// Move groupbox to display title modder...
|
// Move groupbox to display title modder...
|
||||||
contentModBox.Location = new Point(278, 12);
|
contentModBox.Location = new Point(278, 12);
|
||||||
contentModBox.Visible = true;
|
contentModBox.Visible = true;
|
||||||
|
contentModBox.BringToFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button13_Click(object sender, EventArgs e)
|
private void button13_Click(object sender, EventArgs e)
|
||||||
@ -2680,5 +2699,30 @@ namespace NUS_Downloader
|
|||||||
{
|
{
|
||||||
return (Environment.OSVersion.VersionString.Contains("6.1") == true);
|
return (Environment.OSVersion.VersionString.Contains("6.1") == true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private byte[] NewIntegertoByteArray(int theInt, int arrayLen)
|
||||||
|
{
|
||||||
|
byte[] resultArray = new byte[arrayLen];
|
||||||
|
|
||||||
|
for(int i = arrayLen - 1 ; i >= 0; i--)
|
||||||
|
{
|
||||||
|
resultArray[i] = (byte)((theInt >> (8 * i)) & 0xFF);
|
||||||
|
|
||||||
|
}
|
||||||
|
Array.Reverse(resultArray);
|
||||||
|
|
||||||
|
// Fix duplication, rewrite extra to 0x00;
|
||||||
|
if (arrayLen > 4)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < (arrayLen - 4); i++)
|
||||||
|
{
|
||||||
|
resultArray[i] = 0x00;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// DEBUG
|
||||||
|
WriteStatus("byte[] result: " + DisplayBytes(resultArray, " "));
|
||||||
|
return resultArray;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -123,14 +123,6 @@
|
|||||||
<metadata name="databaseStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="databaseStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>159, 17</value>
|
<value>159, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
<data name="label12.Text" xml:space="preserve">
|
|
||||||
<value>Notice:
|
|
||||||
|
|
||||||
* Fake signed content requires an IOS with the fake signing bug to install/use.
|
|
||||||
* Be careful with Ticket values, they are best left alone.
|
|
||||||
* Enter values in decimal, not hexadecimal. Exception: Title ID.
|
|
||||||
* Always have a brick restoration method in place (BootMii boot2).</value>
|
|
||||||
</data>
|
|
||||||
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
<assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||||
<data name="button12.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
<data name="button12.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
<value>
|
<value>
|
||||||
@ -261,7 +253,7 @@
|
|||||||
XTesb3QPLh88M+QwdP6m681Lt7xuXbu94vbgcOjw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DLA2u12AESuWq0WAdjp
|
||||||
/oyAewlgVMoG1Ww2zeVyMeVyORxPpzJmtVqF4EJg+/3eYKDX6wX3wWAQPvOuL76Px2OzXq+9PHfxHz+T
|
/oyAewlgVMoG1Ww2zeVyMeVyORxPpzJmtVqF4EJg+/3eYKDX6wX3wWAQPvOuL76Px2OzXq+9PHfxHz+T
|
||||||
|
@ -63,15 +63,18 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Form1.cs">
|
<Compile Include="Form1.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Form1.Designer.cs">
|
<Compile Include="Form1.Designer.cs">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Program.cs" />
|
<Compile Include="Program.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<EmbeddedResource Include="Form1.resx">
|
<EmbeddedResource Include="Form1.resx">
|
||||||
<DependentUpon>Form1.cs</DependentUpon>
|
<DependentUpon>Form1.cs</DependentUpon>
|
||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
<Generator>ResXFileCodeGenerator</Generator>
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
Loading…
Reference in New Issue
Block a user