mirror of
https://github.com/WiiDatabase/nusdownloader.git
synced 2024-11-23 18:59:16 +01:00
Ran code through "Reorganization"...
This commit is contained in:
parent
fb4ca758f2
commit
9bcd0eba18
1
NUS Downloader/Form1.Designer.cs
generated
1
NUS Downloader/Form1.Designer.cs
generated
@ -567,7 +567,6 @@
|
||||
this.saveaswadbox.TabIndex = 43;
|
||||
this.saveaswadbox.Text = "SaveAs";
|
||||
this.saveaswadbox.UseVisualStyleBackColor = true;
|
||||
this.saveaswadbox.Paint += new System.Windows.Forms.PaintEventHandler(this.saveaswadbox_Paint);
|
||||
//
|
||||
// deletecontentsbox
|
||||
//
|
||||
|
@ -10,7 +10,6 @@ using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Text;
|
||||
using wyDay.Controls;
|
||||
|
||||
using System.Diagnostics;
|
||||
|
||||
|
||||
@ -18,55 +17,86 @@ namespace NUS_Downloader
|
||||
{
|
||||
public partial class Form1 : Form
|
||||
{
|
||||
const string NUSURL = "http://nus.cdn.shop.wii.com/ccs/download/";
|
||||
const string DSiNUSURL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/";
|
||||
private const string WII_NUS_URL = "http://nus.cdn.shop.wii.com/ccs/download/";
|
||||
private const string DSI_NUS_URL = "http://nus.cdn.t.shop.nintendowifi.net/ccs/download/";
|
||||
|
||||
// TODO: Always remember to change version!
|
||||
string version = "v1.5a Beta";
|
||||
WebClient generalWC = new WebClient();
|
||||
static RijndaelManaged rijndaelCipher;
|
||||
static bool dsidecrypt = false;
|
||||
private string version = "v1.5a Beta";
|
||||
private WebClient generalWC = new WebClient();
|
||||
private static RijndaelManaged rijndaelCipher;
|
||||
private static bool dsidecrypt = false;
|
||||
|
||||
// Cross-thread Windows Formsing
|
||||
delegate void AddToolStripItemToStripCallback(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes); //TODO
|
||||
delegate void WriteStatusCallback(string Update);
|
||||
private delegate void AddToolStripItemToStripCallback(
|
||||
int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes);
|
||||
|
||||
//TODO
|
||||
private delegate void WriteStatusCallback(string Update);
|
||||
|
||||
// Images do not compare unless globalized...
|
||||
Image green = Properties.Resources.bullet_green;
|
||||
Image orange = Properties.Resources.bullet_orange;
|
||||
Image redorb = Properties.Resources.bullet_red;
|
||||
Image redgreen = Properties.Resources.bullet_redgreen;
|
||||
Image redorange = Properties.Resources.bullet_redorange;
|
||||
private Image green = Properties.Resources.bullet_green;
|
||||
private Image orange = Properties.Resources.bullet_orange;
|
||||
private Image redorb = Properties.Resources.bullet_red;
|
||||
private Image redgreen = Properties.Resources.bullet_redgreen;
|
||||
private Image redorange = Properties.Resources.bullet_redorange;
|
||||
|
||||
// Certs storage
|
||||
byte[] cert_CA = new byte[0x400];
|
||||
byte[] cert_CACP = new byte[0x300];
|
||||
byte[] cert_CAXS = new byte[0x300];
|
||||
private byte[] cert_CA = new byte[0x400];
|
||||
private byte[] cert_CACP = new byte[0x300];
|
||||
private byte[] cert_CAXS = new byte[0x300];
|
||||
|
||||
byte[] cert_CA_sha1 = new byte[20] {0x5B, 0x7D, 0x3E, 0xE2, 0x87, 0x06, 0xAD, 0x8D, 0xA2, 0xCB, 0xD5, 0xA6, 0xB7, 0x5C, 0x15, 0xD0, 0xF9, 0xB6, 0xF3, 0x18};
|
||||
byte[] cert_CACP_sha1 = new byte[20] {0x68, 0x24, 0xD6, 0xDA, 0x4C, 0x25, 0x18, 0x4F, 0x0D, 0x6D, 0xAF, 0x6E, 0xDB, 0x9C, 0x0F, 0xC5, 0x75, 0x22, 0xA4, 0x1C};
|
||||
byte[] cert_CAXS_sha1 = new byte[20] {0x09, 0x78, 0x70, 0x45, 0x03, 0x71, 0x21, 0x47, 0x78, 0x24, 0xBC, 0x6A, 0x3E, 0x5E, 0x07, 0x61, 0x56, 0x57, 0x3F, 0x8A};
|
||||
private byte[] cert_CA_sha1 = new byte[20]
|
||||
{
|
||||
0x5B, 0x7D, 0x3E, 0xE2, 0x87, 0x06, 0xAD, 0x8D, 0xA2, 0xCB, 0xD5, 0xA6, 0xB7,
|
||||
0x5C, 0x15, 0xD0, 0xF9, 0xB6, 0xF3, 0x18
|
||||
};
|
||||
|
||||
byte[] cert_total_sha1 = new byte[20] {0xAC, 0xE0, 0xF1, 0x5D, 0x2A, 0x85, 0x1C, 0x38, 0x3F, 0xE4, 0x65, 0x7A, 0xFC, 0x38, 0x40, 0xD6, 0xFF, 0xE3, 0x0A, 0xD0};
|
||||
private byte[] cert_CACP_sha1 = new byte[20]
|
||||
{
|
||||
0x68, 0x24, 0xD6, 0xDA, 0x4C, 0x25, 0x18, 0x4F, 0x0D, 0x6D, 0xAF, 0x6E,
|
||||
0xDB, 0x9C, 0x0F, 0xC5, 0x75, 0x22, 0xA4, 0x1C
|
||||
};
|
||||
|
||||
string WAD_Saveas_Filename;
|
||||
private byte[] cert_CAXS_sha1 = new byte[20]
|
||||
{
|
||||
0x09, 0x78, 0x70, 0x45, 0x03, 0x71, 0x21, 0x47, 0x78, 0x24, 0xBC, 0x6A,
|
||||
0x3E, 0x5E, 0x07, 0x61, 0x56, 0x57, 0x3F, 0x8A
|
||||
};
|
||||
|
||||
private byte[] cert_total_sha1 = new byte[20]
|
||||
{
|
||||
0xAC, 0xE0, 0xF1, 0x5D, 0x2A, 0x85, 0x1C, 0x38, 0x3F, 0xE4, 0x65, 0x7A,
|
||||
0xFC, 0x38, 0x40, 0xD6, 0xFF, 0xE3, 0x0A, 0xD0
|
||||
};
|
||||
|
||||
private string WAD_Saveas_Filename;
|
||||
|
||||
// TODO: OOP scripting
|
||||
string script_filename;
|
||||
bool script_mode = false;
|
||||
string[] nusentries;
|
||||
private string script_filename;
|
||||
private bool script_mode = false;
|
||||
private string[] nusentries;
|
||||
|
||||
// Proxy stuff...
|
||||
string proxy_url;
|
||||
string proxy_usr;
|
||||
string proxy_pwd;
|
||||
private string proxy_url;
|
||||
private string proxy_usr;
|
||||
private string proxy_pwd;
|
||||
|
||||
// Database thread
|
||||
private BackgroundWorker fds;
|
||||
|
||||
// Common Key hash
|
||||
byte[] wii_commonkey_sha1 = new byte[20] { 0xEB, 0xEA, 0xE6, 0xD2, 0x76, 0x2D, 0x4D, 0x3E, 0xA1, 0x60, 0xA6, 0xD8, 0x32, 0x7F, 0xAC, 0x9A, 0x25, 0xF8, 0x06, 0x2B };
|
||||
byte[] wii_commonkey_sha1_asstring = new byte[20] { 0x56, 0xdd, 0x4e, 0xb3, 0x59, 0x75, 0xc2, 0xfd, 0x5a, 0xe8, 0xba, 0x8c, 0x7d, 0x89, 0x9a, 0xc5, 0xe6, 0x17, 0x54, 0x19 };
|
||||
private byte[] wii_commonkey_sha1 = new byte[20]
|
||||
{
|
||||
0xEB, 0xEA, 0xE6, 0xD2, 0x76, 0x2D, 0x4D, 0x3E, 0xA1, 0x60, 0xA6, 0xD8,
|
||||
0x32, 0x7F, 0xAC, 0x9A, 0x25, 0xF8, 0x06, 0x2B
|
||||
};
|
||||
|
||||
private byte[] wii_commonkey_sha1_asstring = new byte[20]
|
||||
{
|
||||
0x56, 0xdd, 0x4e, 0xb3, 0x59, 0x75, 0xc2, 0xfd, 0x5a, 0xe8,
|
||||
0xba, 0x8c, 0x7d, 0x89, 0x9a, 0xc5, 0xe6, 0x17, 0x54, 0x19
|
||||
};
|
||||
|
||||
/*
|
||||
public struct WADHeader
|
||||
{
|
||||
@ -89,8 +119,10 @@ namespace NUS_Downloader
|
||||
public byte[] SHAHash;
|
||||
} ;
|
||||
|
||||
public enum ContentTypes : int {
|
||||
Shared = 0x8001, Normal = 0x0001
|
||||
public enum ContentTypes : int
|
||||
{
|
||||
Shared = 0x8001,
|
||||
Normal = 0x0001
|
||||
}
|
||||
|
||||
// This is the standard entry to the GUI
|
||||
@ -241,10 +273,13 @@ namespace NUS_Downloader
|
||||
else
|
||||
{
|
||||
WriteStatus("Common Key detected.");
|
||||
if ((Convert.ToBase64String(ComputeSHA(LoadCommonKey("key.bin")))) != (Convert.ToBase64String(wii_commonkey_sha1)))
|
||||
{ // Hmm, seems to be a bad hash
|
||||
if ((Convert.ToBase64String(ComputeSHA(LoadCommonKey("key.bin")))) !=
|
||||
(Convert.ToBase64String(wii_commonkey_sha1)))
|
||||
{
|
||||
// Hmm, seems to be a bad hash
|
||||
// Let's check if it matches the hex string version...
|
||||
if ((Convert.ToBase64String(ComputeSHA(LoadCommonKey("key.bin")))) != (Convert.ToBase64String(wii_commonkey_sha1_asstring)))
|
||||
if ((Convert.ToBase64String(ComputeSHA(LoadCommonKey("key.bin")))) !=
|
||||
(Convert.ToBase64String(wii_commonkey_sha1_asstring)))
|
||||
WriteStatus(" - (PS: Your common key isn't hashing right!)");
|
||||
else
|
||||
{
|
||||
@ -304,8 +339,10 @@ namespace NUS_Downloader
|
||||
{
|
||||
proxy_usr = proxy_file[1];
|
||||
SetAllEnabled(false);
|
||||
ProxyVerifyBox.Visible = true; ProxyVerifyBox.Enabled = true;
|
||||
ProxyPwdBox.Enabled = true; SaveProxyBtn.Enabled = true;
|
||||
ProxyVerifyBox.Visible = true;
|
||||
ProxyVerifyBox.Enabled = true;
|
||||
ProxyPwdBox.Enabled = true;
|
||||
SaveProxyBtn.Enabled = true;
|
||||
ProxyVerifyBox.Select();
|
||||
}
|
||||
}
|
||||
@ -435,7 +472,9 @@ namespace NUS_Downloader
|
||||
// Loop through each content and display name, hash, index
|
||||
for (int i = 0; i < nbr_cont; i++)
|
||||
{
|
||||
WriteStatus(" Content " + (i + 1) + ": " + tmdcontents[i] + " (" + Convert.ToString(int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber)) + " bytes)");
|
||||
WriteStatus(" Content " + (i + 1) + ": " + tmdcontents[i] + " (" +
|
||||
Convert.ToString(int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber)) +
|
||||
" bytes)");
|
||||
byte[] hash = new byte[20];
|
||||
for (int x = 0; x < 20; x++)
|
||||
{
|
||||
@ -458,7 +497,8 @@ namespace NUS_Downloader
|
||||
string sysversion = "";
|
||||
for (int i = 0; i < 8; i++)
|
||||
sysversion += MakeProperLength(ConvertToHex(Convert.ToString(tmd[0x184 + i])));
|
||||
sysversion = Convert.ToString(int.Parse(sysversion.Substring(14, 2), System.Globalization.NumberStyles.HexNumber));
|
||||
sysversion =
|
||||
Convert.ToString(int.Parse(sysversion.Substring(14, 2), System.Globalization.NumberStyles.HexNumber));
|
||||
return sysversion;
|
||||
}
|
||||
|
||||
@ -844,7 +884,8 @@ namespace NUS_Downloader
|
||||
// Current directory...
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) ||
|
||||
!(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
// Prevent crossthread issues
|
||||
@ -899,7 +940,6 @@ namespace NUS_Downloader
|
||||
{
|
||||
// Windows 7 Taskbar progress can be used.
|
||||
dlprogress.ShowInTaskbar = true;
|
||||
|
||||
}
|
||||
|
||||
// Download TMD before the rest...
|
||||
@ -912,7 +952,6 @@ namespace NUS_Downloader
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
WriteStatus("Download Failed: " + tmdfull);
|
||||
WriteStatus(" - Reason: " + ex.Message.ToString().Replace("The remote server returned an error: ", ""));
|
||||
SetEnableforDownload(true);
|
||||
@ -935,7 +974,8 @@ namespace NUS_Downloader
|
||||
if (ignoreticket.Checked == false)
|
||||
{
|
||||
WriteStatus("Download Failed: cetk");
|
||||
WriteStatus(" - Reason: " + ex.Message.ToString().Replace("The remote server returned an error: ", ""));
|
||||
WriteStatus(" - Reason: " +
|
||||
ex.Message.ToString().Replace("The remote server returned an error: ", ""));
|
||||
WriteStatus("You may be able to retrieve the contents by Ignoring the Ticket (Check below)");
|
||||
SetEnableforDownload(true);
|
||||
downloadstartbtn.Text = "Start NUS Download!";
|
||||
@ -1079,13 +1119,15 @@ namespace NUS_Downloader
|
||||
}
|
||||
else
|
||||
{
|
||||
DownloadNUSFile(titleid, tmdcontents[i], titledirectory, int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber), wiimode);
|
||||
DownloadNUSFile(titleid, tmdcontents[i], titledirectory,
|
||||
int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber), wiimode);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteStatus("Download Failed: " + tmdcontents[i]);
|
||||
WriteStatus(" - Reason: " + ex.Message.ToString().Replace("The remote server returned an error: ", ""));
|
||||
WriteStatus(" - Reason: " +
|
||||
ex.Message.ToString().Replace("The remote server returned an error: ", ""));
|
||||
SetEnableforDownload(true);
|
||||
downloadstartbtn.Text = "Start NUS Download!";
|
||||
dlprogress.Value = 0;
|
||||
@ -1094,14 +1136,16 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
// Progress reporting advances...
|
||||
downloadstartbtn.Text = "Content: (" + (i + 1) + Path.AltDirectorySeparatorChar.ToString() + contentstrnum + ")";
|
||||
downloadstartbtn.Text = "Content: (" + (i + 1) + Path.AltDirectorySeparatorChar.ToString() +
|
||||
contentstrnum + ")";
|
||||
currentcontentlocation += int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber);
|
||||
|
||||
// Decrypt stuff...
|
||||
if (decryptbox.Checked == true)
|
||||
{
|
||||
// Create content file holder
|
||||
byte[] contbuf = FileLocationToByteArray(titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i]);
|
||||
byte[] contbuf =
|
||||
FileLocationToByteArray(titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i]);
|
||||
|
||||
// IV (00+IDX+more000)
|
||||
byte[] iv = new byte[16];
|
||||
@ -1120,7 +1164,10 @@ namespace NUS_Downloader
|
||||
decfs.Close();
|
||||
WriteStatus(" - Decrypted: " + zeros + i.ToString("X2") + ".app"); */
|
||||
|
||||
FileStream decfs = new FileStream(titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i] + ".app", FileMode.Create);
|
||||
FileStream decfs =
|
||||
new FileStream(
|
||||
titledirectory + Path.DirectorySeparatorChar.ToString() + tmdcontents[i] + ".app",
|
||||
FileMode.Create);
|
||||
decfs.Write(Decrypt(contbuf), 0, int.Parse(tmdsizes[i], System.Globalization.NumberStyles.HexNumber));
|
||||
decfs.Close();
|
||||
WriteStatus(" - Decrypted: " + tmdcontents[i] + ".app");
|
||||
@ -1164,7 +1211,6 @@ namespace NUS_Downloader
|
||||
|
||||
if (script_mode)
|
||||
statusbox.Text = "";
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1182,7 +1228,9 @@ namespace NUS_Downloader
|
||||
if (titleversion.Text == "")
|
||||
titledirectory = Path.Combine(currentdir, titleidbox.Text + Path.DirectorySeparatorChar.ToString());
|
||||
else
|
||||
titledirectory = Path.Combine(currentdir, titleidbox.Text + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString());
|
||||
titledirectory = Path.Combine(currentdir,
|
||||
titleidbox.Text + "v" + titleversion.Text +
|
||||
Path.DirectorySeparatorChar.ToString());
|
||||
|
||||
// Keep local directory if present and checked out...
|
||||
if ((localuse.Checked) && (Directory.Exists(titledirectory)))
|
||||
@ -1212,7 +1260,9 @@ namespace NUS_Downloader
|
||||
if (titleversion.Text == "")
|
||||
titledirectory = Path.Combine(currentdir, titleidbox.Text + Path.DirectorySeparatorChar.ToString());
|
||||
else
|
||||
titledirectory = Path.Combine(currentdir, titleidbox.Text + "v" + titleversion.Text + Path.DirectorySeparatorChar.ToString());
|
||||
titledirectory = Path.Combine(currentdir,
|
||||
titleidbox.Text + "v" + titleversion.Text +
|
||||
Path.DirectorySeparatorChar.ToString());
|
||||
|
||||
if (Directory.Exists(titledirectory))
|
||||
Directory.Delete(titledirectory, true);
|
||||
@ -1228,14 +1278,15 @@ namespace NUS_Downloader
|
||||
/// <param name="placementdir">The placementdir.</param>
|
||||
/// <param name="sizeinbytes">The sizeinbytes.</param>
|
||||
/// <param name="iswiititle">if set to <c>true</c> [iswiititle].</param>
|
||||
private void DownloadNUSFile(string titleid, string filename, string placementdir, int sizeinbytes, bool iswiititle)
|
||||
private void DownloadNUSFile(string titleid, string filename, string placementdir, int sizeinbytes,
|
||||
bool iswiititle)
|
||||
{
|
||||
// Create NUS URL...
|
||||
string nusfileurl;
|
||||
if (iswiititle)
|
||||
nusfileurl = NUSURL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename;
|
||||
nusfileurl = WII_NUS_URL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename;
|
||||
else
|
||||
nusfileurl = DSiNUSURL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename;
|
||||
nusfileurl = DSI_NUS_URL + titleid + Path.AltDirectorySeparatorChar.ToString() + filename;
|
||||
|
||||
WriteStatus("Grabbing " + filename + "...");
|
||||
|
||||
@ -1247,7 +1298,7 @@ namespace NUS_Downloader
|
||||
generalWC.DownloadFile(nusfileurl, placementdir + filename);
|
||||
}
|
||||
|
||||
void StatusChange(string status)
|
||||
private void StatusChange(string status)
|
||||
{
|
||||
WriteStatus(status);
|
||||
}
|
||||
@ -1264,7 +1315,8 @@ namespace NUS_Downloader
|
||||
|
||||
// Obtain Current Directory
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) ||
|
||||
!(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
// Create instance of WAD Packing class
|
||||
@ -1312,7 +1364,8 @@ namespace NUS_Downloader
|
||||
}
|
||||
else
|
||||
{
|
||||
string wad_filename = totaldirectory + Path.DirectorySeparatorChar.ToString() + RemoveIllegalCharacters(wadnamebox.Text);
|
||||
string wad_filename = totaldirectory + Path.DirectorySeparatorChar.ToString() +
|
||||
RemoveIllegalCharacters(wadnamebox.Text);
|
||||
packer.Directory = totaldirectory;
|
||||
packer.FileName = System.IO.Path.GetFileName(wad_filename);
|
||||
}
|
||||
@ -1347,6 +1400,7 @@ namespace NUS_Downloader
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/// <summary>
|
||||
/// Returns next 0x40 padded length.
|
||||
/// </summary>
|
||||
@ -1386,7 +1440,7 @@ namespace NUS_Downloader
|
||||
Array.Reverse(b);
|
||||
|
||||
return b;
|
||||
}
|
||||
}*/
|
||||
|
||||
private void consoleCBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
@ -1474,7 +1528,6 @@ namespace NUS_Downloader
|
||||
wadnamebox.Enabled = false;
|
||||
wadnamebox.Text = "";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void titleidbox_TextChanged(object sender, EventArgs e)
|
||||
@ -1578,7 +1631,7 @@ namespace NUS_Downloader
|
||||
/// </summary>
|
||||
/// <param name="data">A byte[].</param>
|
||||
/// <returns></returns>
|
||||
static public byte[] ComputeSHA(byte[] data)
|
||||
public static byte[] ComputeSHA(byte[] data)
|
||||
{
|
||||
SHA1 sha = new SHA1CryptoServiceProvider();
|
||||
// This is one implementation of the abstract class SHA1.
|
||||
@ -1594,7 +1647,8 @@ namespace NUS_Downloader
|
||||
{
|
||||
// Directory stuff
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) ||
|
||||
!(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
if (File.Exists(currentdir + keyfile) == true)
|
||||
@ -1699,6 +1753,7 @@ namespace NUS_Downloader
|
||||
// Okay, so now report the progress...
|
||||
rnt = rnt + 1;
|
||||
float currentProgress = ((float) rnt/(float) totalLength)*(float) 100;
|
||||
if (Convert.ToInt16(Math.Round(currentProgress))%10 == 0)
|
||||
worker.ReportProgress(Convert.ToInt16(Math.Round(currentProgress)));
|
||||
|
||||
// Lol.
|
||||
@ -1716,7 +1771,8 @@ namespace NUS_Downloader
|
||||
break;
|
||||
case "titleIDs":
|
||||
updateScript = ChildrenOfTheNode[z].InnerText;
|
||||
XMLToolStripItem.AccessibleDescription = updateScript; // TODO: Find somewhere better to put this. AND FAST.
|
||||
XMLToolStripItem.AccessibleDescription = updateScript;
|
||||
// TODO: Find somewhere better to put this. AND FAST.
|
||||
break;
|
||||
case "version":
|
||||
string[] versions = ChildrenOfTheNode[z].InnerText.Split(',');
|
||||
@ -1727,13 +1783,15 @@ namespace NUS_Downloader
|
||||
{
|
||||
if (ChildrenOfTheNode[z].InnerText != "")
|
||||
{
|
||||
ToolStripMenuItem regitem = (ToolStripMenuItem)XMLToolStripItem.DropDownItems[b];
|
||||
ToolStripMenuItem regitem =
|
||||
(ToolStripMenuItem) XMLToolStripItem.DropDownItems[b];
|
||||
regitem.DropDownItems.Add("Latest Version");
|
||||
for (int y = 0; y < versions.Length; y++)
|
||||
{
|
||||
regitem.DropDownItems.Add("v" + versions[y]);
|
||||
}
|
||||
regitem.DropDownItemClicked += new ToolStripItemClickedEventHandler(deepitem_clicked);
|
||||
regitem.DropDownItemClicked +=
|
||||
new ToolStripItemClickedEventHandler(deepitem_clicked);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1755,7 +1813,8 @@ namespace NUS_Downloader
|
||||
{
|
||||
for (int y = 0; y < regions.Length; y++)
|
||||
{
|
||||
XMLToolStripItem.DropDownItems.Add(RegionFromIndex(Convert.ToInt32(regions[y]), xDoc));
|
||||
XMLToolStripItem.DropDownItems.Add(RegionFromIndex(Convert.ToInt32(regions[y]),
|
||||
xDoc));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1791,9 +1850,9 @@ namespace NUS_Downloader
|
||||
/// <param name="type">The type.</param>
|
||||
/// <param name="additionitem">The additionitem.</param>
|
||||
/// <param name="attributes">The attributes.</param>
|
||||
void AddToolStripItemToStrip(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes)
|
||||
private void AddToolStripItemToStrip(int type, ToolStripMenuItem additionitem, XmlAttributeCollection attributes)
|
||||
{
|
||||
Debug.WriteLine("Adding item...");
|
||||
Debug.WriteLine(String.Format("Adding item (Type: {0})...", type));
|
||||
// Check if thread-safe
|
||||
if (this.InvokeRequired)
|
||||
{
|
||||
@ -1891,7 +1950,7 @@ namespace NUS_Downloader
|
||||
}
|
||||
}
|
||||
|
||||
void deepitem_clicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
private void deepitem_clicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
titleidbox.Text = e.ClickedItem.OwnerItem.OwnerItem.Text.Substring(0, 16);
|
||||
titleidbox.Text = titleidbox.Text.Replace("XX", e.ClickedItem.OwnerItem.Text.Substring(0, 2));
|
||||
@ -1912,11 +1971,14 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
// Prepare StatusBox...
|
||||
string titlename = e.ClickedItem.OwnerItem.OwnerItem.Text.Substring(19, (e.ClickedItem.OwnerItem.OwnerItem.Text.Length - 19));
|
||||
string titlename = e.ClickedItem.OwnerItem.OwnerItem.Text.Substring(19,
|
||||
(e.ClickedItem.OwnerItem.OwnerItem.Text.
|
||||
Length - 19));
|
||||
statusbox.Text = " --- " + titlename + " ---";
|
||||
|
||||
// Check if a ticket is present...
|
||||
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (orange) || (e.ClickedItem.OwnerItem.OwnerItem.Image) == (redorange))
|
||||
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (orange) ||
|
||||
(e.ClickedItem.OwnerItem.OwnerItem.Image) == (redorange))
|
||||
{
|
||||
ignoreticket.Checked = true;
|
||||
WriteStatus("Note: This title has no ticket and cannot be packed/decrypted!");
|
||||
@ -1935,7 +1997,8 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
// Check for danger item
|
||||
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (redgreen) || (e.ClickedItem.OwnerItem.OwnerItem.Image) == (redorange))
|
||||
if ((e.ClickedItem.OwnerItem.OwnerItem.Image) == (redgreen) ||
|
||||
(e.ClickedItem.OwnerItem.OwnerItem.Image) == (redorange))
|
||||
{
|
||||
WriteStatus("\r\n" + e.ClickedItem.OwnerItem.OwnerItem.ToolTipText);
|
||||
}
|
||||
@ -1970,7 +2033,7 @@ namespace NUS_Downloader
|
||||
wadnamebox.Text = wadnamebox.Text.Replace("[v]", "v" + titleversion.Text);
|
||||
}
|
||||
|
||||
void wwitem_regionclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
private void wwitem_regionclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
titleidbox.Text = e.ClickedItem.OwnerItem.Text.Substring(0, 16);
|
||||
titleversion.Text = "";
|
||||
@ -2006,14 +2069,15 @@ namespace NUS_Downloader
|
||||
}
|
||||
}
|
||||
|
||||
void upditem_itemclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
private void upditem_itemclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
WriteStatus("Preparing to run download script...");
|
||||
Control.CheckForIllegalCrossThreadCalls = false;
|
||||
script_mode = true;
|
||||
statusbox.Text = "";
|
||||
WriteStatus("Starting script download. Please be patient!");
|
||||
string[] NUS_Entries = e.ClickedItem.AccessibleDescription.Split('\n'); // TODO: Find somewhere better to put this. AND FAST!
|
||||
string[] NUS_Entries = e.ClickedItem.AccessibleDescription.Split('\n');
|
||||
// TODO: Find somewhere better to put this. AND FAST!
|
||||
for (int i = 0; i < NUS_Entries.Length; i++)
|
||||
{
|
||||
WriteStatus(NUS_Entries[i]);
|
||||
@ -2026,7 +2090,7 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
|
||||
void sysitem_versionclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
private void sysitem_versionclicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
{
|
||||
titleidbox.Text = e.ClickedItem.OwnerItem.Text.Substring(0, 16);
|
||||
|
||||
@ -2091,7 +2155,7 @@ namespace NUS_Downloader
|
||||
/// <param name="index">The index.</param>
|
||||
/// <param name="databasexml">XmlDocument with database inside</param>
|
||||
/// <returns>Region desc</returns>
|
||||
string RegionFromIndex(int index, XmlDocument databasexml)
|
||||
private string RegionFromIndex(int index, XmlDocument databasexml)
|
||||
{
|
||||
/* Typical Region XML
|
||||
* <REGIONS>
|
||||
@ -2157,7 +2221,7 @@ namespace NUS_Downloader
|
||||
/// </summary>
|
||||
/// <param name="databasestr">removes the illegal chars</param>
|
||||
/// <returns>legal string</returns>
|
||||
private string RemoveIllegalCharacters(string databasestr)
|
||||
private static string RemoveIllegalCharacters(string databasestr)
|
||||
{
|
||||
// Database strings must contain filename-legal characters.
|
||||
foreach (char illegalchar in System.IO.Path.GetInvalidFileNameChars())
|
||||
@ -2168,67 +2232,13 @@ namespace NUS_Downloader
|
||||
return databasestr;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Zeroes the signature in TMD/TIK.
|
||||
/// </summary>
|
||||
/// <param name="tmdortik">TMD/TIK</param>
|
||||
/// <returns>Zeroed TMD/TIK</returns>
|
||||
private byte[] ZeroSignature(byte[] tmdortik)
|
||||
{
|
||||
// Write all 0x00 to signature...
|
||||
// Sig starts at 0x04 in both TMD/TIK
|
||||
for (int i = 0; i < 256; i++)
|
||||
{
|
||||
tmdortik[i + 4] = 0x00;
|
||||
}
|
||||
|
||||
WriteStatus(" - Signature Emptied...");
|
||||
return tmdortik;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trucha Signs a TMD/TIK
|
||||
/// </summary>
|
||||
/// <param name="tmdortik">The tmdortik.</param>
|
||||
/// <returns>Fake-signed byte[]</returns>
|
||||
private byte[] TruchaSign(byte[] tmdortik)
|
||||
{
|
||||
// Loop through 2 bytes worth of numbers until hash starts with 0x00...
|
||||
// Padding starts at 0x104 in both TMD/TIK, seems like a good place to me...
|
||||
|
||||
byte[] payload = new byte[2];
|
||||
byte[] hashobject = new byte[tmdortik.Length - 0x104];
|
||||
|
||||
for (int i = 0; i < 65535; i++)
|
||||
{
|
||||
payload = incrementAtIndex(payload, 1);
|
||||
|
||||
tmdortik[0x104] = payload[0];
|
||||
tmdortik[0x105] = payload[1];
|
||||
|
||||
for (int x = 0; x < (tmdortik.Length - 0x104); x++)
|
||||
{
|
||||
hashobject[x] = tmdortik[0x104 + x];
|
||||
}
|
||||
|
||||
if (ComputeSHA(hashobject)[0] == 0x00)
|
||||
{
|
||||
WriteStatus(" - Successfully Trucha Signed.");
|
||||
return tmdortik;
|
||||
}
|
||||
}
|
||||
|
||||
WriteStatus(" - Sign FAIL!");
|
||||
return tmdortik;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Increments at an index.
|
||||
/// </summary>
|
||||
/// <param name="array">The array.</param>
|
||||
/// <param name="index">The index.</param>
|
||||
/// <returns></returns>
|
||||
static public byte[] incrementAtIndex(byte[] array, int index)
|
||||
public static byte[] incrementAtIndex(byte[] array, int index)
|
||||
{
|
||||
if (array[index] == byte.MaxValue)
|
||||
{
|
||||
@ -2286,7 +2296,6 @@ namespace NUS_Downloader
|
||||
{
|
||||
// Do nothing, some objects will not cast.
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -2360,7 +2369,6 @@ namespace NUS_Downloader
|
||||
}
|
||||
}
|
||||
wadnamebox.Text = RemoveIllegalCharacters(wadnamebox.Text);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -2374,10 +2382,15 @@ namespace NUS_Downloader
|
||||
byte[] Ticket = new byte[0x2A4];
|
||||
|
||||
// RSA Signature Heading...
|
||||
Ticket[1] = 0x01; Ticket[3] = 0x01;
|
||||
Ticket[1] = 0x01;
|
||||
Ticket[3] = 0x01;
|
||||
|
||||
// Signature Issuer... (Root-CA00000001-XS00000003)
|
||||
byte[] SignatureIssuer = new byte[0x1A] { 0x52, 0x6F, 0x6F, 0x74, 0x2D, 0x43, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x31, 0x2D, 0x58, 0x53, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33 };
|
||||
byte[] SignatureIssuer = new byte[0x1A]
|
||||
{
|
||||
0x52, 0x6F, 0x6F, 0x74, 0x2D, 0x43, 0x41, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
|
||||
0x30, 0x31, 0x2D, 0x58, 0x53, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x33
|
||||
};
|
||||
for (int a = 0; a < 0x40; a++)
|
||||
{
|
||||
Ticket[0x140 + a] = SignatureIssuer[a];
|
||||
@ -2402,8 +2415,10 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
// Misc FF...
|
||||
Ticket[0x1E4] = 0xFF; Ticket[0x1E5] = 0xFF;
|
||||
Ticket[0x1E6] = 0xFF; Ticket[0x1E7] = 0xFF;
|
||||
Ticket[0x1E4] = 0xFF;
|
||||
Ticket[0x1E5] = 0xFF;
|
||||
Ticket[0x1E6] = 0xFF;
|
||||
Ticket[0x1E7] = 0xFF;
|
||||
|
||||
// Unknown 0x01...
|
||||
Ticket[0x221] = 0x01;
|
||||
@ -2427,12 +2442,6 @@ namespace NUS_Downloader
|
||||
return System.Text.RegularExpressions.Regex.IsMatch(test, @"\A\b[0-9a-fA-F]+\b\Z");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Pads to multiple of....
|
||||
/// </summary>
|
||||
@ -2447,11 +2456,6 @@ namespace NUS_Downloader
|
||||
return src;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines whether OS is win7.
|
||||
/// </summary>
|
||||
@ -2470,7 +2474,6 @@ namespace NUS_Downloader
|
||||
for (int i = arrayLen - 1; i >= 0; i--)
|
||||
{
|
||||
resultArray[i] = (byte) ((theInt >> (8*i)) & 0xFF);
|
||||
|
||||
}
|
||||
Array.Reverse(resultArray);
|
||||
|
||||
@ -2486,7 +2489,6 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Does byte[] contain byte[]?
|
||||
/// </summary>
|
||||
@ -2552,7 +2554,9 @@ namespace NUS_Downloader
|
||||
databasedl.UseDefaultCredentials = true;
|
||||
}
|
||||
|
||||
string wiibrewsource = databasedl.DownloadString("http://www.wiibrew.org/wiki/NUS_Downloader/database?cachesmash=" + System.DateTime.Now.ToString());
|
||||
string wiibrewsource =
|
||||
databasedl.DownloadString("http://www.wiibrew.org/wiki/NUS_Downloader/database?cachesmash=" +
|
||||
System.DateTime.Now.ToString());
|
||||
//statusbox.Refresh();
|
||||
|
||||
// Strip out HTML
|
||||
@ -2561,7 +2565,8 @@ namespace NUS_Downloader
|
||||
// Shrink to fix only the database
|
||||
string startofdatabase = "<database v";
|
||||
string endofdatabase = "</database>";
|
||||
wiibrewsource = wiibrewsource.Substring(wiibrewsource.IndexOf(startofdatabase), wiibrewsource.Length - wiibrewsource.IndexOf(startofdatabase));
|
||||
wiibrewsource = wiibrewsource.Substring(wiibrewsource.IndexOf(startofdatabase),
|
||||
wiibrewsource.Length - wiibrewsource.IndexOf(startofdatabase));
|
||||
wiibrewsource = wiibrewsource.Substring(0, wiibrewsource.IndexOf(endofdatabase) + endofdatabase.Length);
|
||||
|
||||
// Fix ", <, >, and spaces
|
||||
@ -2576,7 +2581,6 @@ namespace NUS_Downloader
|
||||
|
||||
private void RetrieveNewDatabase_Completed(object sender, RunWorkerCompletedEventArgs e)
|
||||
{
|
||||
|
||||
string database = e.Result.ToString();
|
||||
string currentversion = GetDatabaseVersion("database.xml");
|
||||
string onlineversion = GetDatabaseVersion(database);
|
||||
@ -2623,7 +2627,6 @@ namespace NUS_Downloader
|
||||
{
|
||||
WriteStatus("Database successfully updated!");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void updateDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
@ -2654,7 +2657,9 @@ namespace NUS_Downloader
|
||||
/// <returns></returns>
|
||||
public string SendSOAPRequest(string soap_xml)
|
||||
{
|
||||
System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create("http://nus.shop.wii.com:80/nus/services/NetUpdateSOAP");
|
||||
System.Net.HttpWebRequest req =
|
||||
(System.Net.HttpWebRequest)
|
||||
System.Net.HttpWebRequest.Create("http://nus.shop.wii.com:80/nus/services/NetUpdateSOAP");
|
||||
req.Method = "POST";
|
||||
req.UserAgent = "wii libnup/1.0";
|
||||
req.Headers.Add("SOAPAction", '"' + "urn:nus.wsapi.broadon.com/" + '"');
|
||||
@ -2716,7 +2721,6 @@ namespace NUS_Downloader
|
||||
|
||||
return ex.Message.ToString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void emulateUpdate_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
|
||||
@ -2746,11 +2750,14 @@ namespace NUS_Downloader
|
||||
" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"" +
|
||||
" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
|
||||
"<soapenv:Body>\n<GetSystemUpdateRequest xmlns=\"urn:nus.wsapi.broadon.com\">\n" +
|
||||
"<Version>1.0</Version>\n<MessageId>" + messageID + "</MessageId>\n<DeviceId>" + deviceID + "</DeviceId>\n" +
|
||||
"<RegionId>" + RegionID + "</RegionId>\n<CountryCode>" + CountryCode + "</CountryCode>\n<TitleVersion>\n<TitleId>0000000100000001</TitleId>\n" +
|
||||
"<Version>1.0</Version>\n<MessageId>" + messageID + "</MessageId>\n<DeviceId>" + deviceID +
|
||||
"</DeviceId>\n" +
|
||||
"<RegionId>" + RegionID + "</RegionId>\n<CountryCode>" + CountryCode +
|
||||
"</CountryCode>\n<TitleVersion>\n<TitleId>0000000100000001</TitleId>\n" +
|
||||
"<Version>2</Version>\n</TitleVersion>\n<TitleVersion>\n<TitleId>0000000100000002</TitleId>\n" +
|
||||
"<Version>33</Version>\n</TitleVersion>\n<TitleVersion>\n<TitleId>0000000100000009</TitleId>\n" +
|
||||
"<Version>516</Version>\n</TitleVersion>\n<Attribute>" + attr + "</Attribute>\n<AuditData></AuditData>\n" +
|
||||
"<Version>516</Version>\n</TitleVersion>\n<Attribute>" + attr +
|
||||
"</Attribute>\n<AuditData></AuditData>\n" +
|
||||
"</GetSystemUpdateRequest>\n</soapenv:Body>\n</soapenv:Envelope>";
|
||||
|
||||
WriteStatus(" - Sending SOAP Request to NUS...");
|
||||
@ -2795,23 +2802,24 @@ namespace NUS_Downloader
|
||||
if ((File.Exists("database.xml") == true) && ((!(String.IsNullOrEmpty(NameFromDatabase(TitleID))))))
|
||||
statusbox.Text += String.Format(" [{0}]", NameFromDatabase(TitleID));
|
||||
|
||||
script_text += String.Format("{0} {1}\n", TitleID, DisplayBytes(NewIntegertoByteArray(Convert.ToInt32(Version), 2), ""));
|
||||
script_text += String.Format("{0} {1}\n", TitleID,
|
||||
DisplayBytes(NewIntegertoByteArray(Convert.ToInt32(Version), 2), ""));
|
||||
}
|
||||
|
||||
WriteStatus(" - Outputting results to NUS script...");
|
||||
|
||||
// Current directory...
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
if (!(Directory.Exists(currentdir + "scripts")))
|
||||
if (!(Directory.Exists(Path.Combine(currentdir, "scripts"))))
|
||||
{
|
||||
Directory.CreateDirectory(currentdir + "scripts");
|
||||
Directory.CreateDirectory(Path.Combine(currentdir, "scripts"));
|
||||
WriteStatus(" - Created 'scripts\' directory.");
|
||||
}
|
||||
string time = RemoveIllegalCharacters(DateTime.Now.ToShortTimeString());
|
||||
File.WriteAllText(String.Format(currentdir + "scripts\\{0}_Update_{1}_{2}_{3} {4}.nus", RegionID, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, time), script_text);
|
||||
File.WriteAllText(
|
||||
String.Format(Path.Combine(currentdir, "scripts\\{0}_Update_{1}_{2}_{3} {4}.nus"), RegionID,
|
||||
DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Year, time), script_text);
|
||||
WriteStatus(" - Script written!");
|
||||
WriteStatus(" - Run this script if you feel like downloading the update!");
|
||||
}
|
||||
@ -2860,7 +2868,8 @@ namespace NUS_Downloader
|
||||
}
|
||||
|
||||
// Search for cert_CA
|
||||
if ((!(tmdortik.Length < 0x400)) && ((Convert.ToBase64String(ComputeSHA(cert_CA)) != Convert.ToBase64String(cert_CA_sha1))))
|
||||
if ((!(tmdortik.Length < 0x400)) &&
|
||||
((Convert.ToBase64String(ComputeSHA(cert_CA)) != Convert.ToBase64String(cert_CA_sha1))))
|
||||
{
|
||||
for (int a = 0; a < (tmdortik.Length - 0x400); a++)
|
||||
{
|
||||
@ -2945,7 +2954,9 @@ namespace NUS_Downloader
|
||||
case "titleID":
|
||||
if (ChildrenOfTheNode[z].InnerText == titleid)
|
||||
found_it = true;
|
||||
else if ((ChildrenOfTheNode[z].InnerText.Substring(0, 14) + "XX") == (titleid.Substring(0, 14) + "XX") && (titleid.Substring(0, 14) != "00000001000000"))
|
||||
else if ((ChildrenOfTheNode[z].InnerText.Substring(0, 14) + "XX") ==
|
||||
(titleid.Substring(0, 14) + "XX") &&
|
||||
(titleid.Substring(0, 14) != "00000001000000"))
|
||||
found_it = true;
|
||||
else
|
||||
found_it = false;
|
||||
@ -2979,32 +2990,24 @@ namespace NUS_Downloader
|
||||
deletecontentsbox.Enabled = packbox.Enabled;
|
||||
}
|
||||
|
||||
private void saveaswadbox_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
//e.Graphics.
|
||||
/*Rectangle rect = new Rectangle(0, 0, 16, 16);
|
||||
if (saveaswadbox.Checked)
|
||||
e.Graphics.DrawImageUnscaledAndClipped(green, rect);
|
||||
else
|
||||
e.Graphics.DrawImageUnscaled(orange, -7, -5); */
|
||||
}
|
||||
|
||||
private void SaveProxyBtn_Click(object sender, EventArgs e)
|
||||
{
|
||||
// Current directory...
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) && ((File.Exists(currentdir + "proxy.txt"))))
|
||||
if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) &&
|
||||
((File.Exists(Path.Combine(currentdir, "proxy.txt")))))
|
||||
{
|
||||
File.Delete(currentdir + "proxy.txt");
|
||||
File.Delete(Path.Combine(currentdir, "proxy.txt"));
|
||||
proxyBox.Visible = false;
|
||||
proxy_usr = ""; proxy_url = ""; proxy_pwd = "";
|
||||
proxy_usr = "";
|
||||
proxy_url = "";
|
||||
proxy_pwd = "";
|
||||
WriteStatus("Proxy settings deleted!");
|
||||
return;
|
||||
}
|
||||
else if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) && ((!(File.Exists(currentdir + "proxy.txt")))))
|
||||
else if ((String.IsNullOrEmpty(ProxyURL.Text)) && (String.IsNullOrEmpty(ProxyUser.Text)) &&
|
||||
((!(File.Exists(Path.Combine(currentdir, "proxy.txt"))))))
|
||||
{
|
||||
proxyBox.Visible = false;
|
||||
WriteStatus("No proxy settings saved!");
|
||||
@ -3027,15 +3030,17 @@ namespace NUS_Downloader
|
||||
|
||||
if (!(String.IsNullOrEmpty(proxy_file)))
|
||||
{
|
||||
File.WriteAllText(currentdir + "proxy.txt", proxy_file);
|
||||
File.WriteAllText(Path.Combine(currentdir, "proxy.txt"), proxy_file);
|
||||
WriteStatus("Proxy settings saved!");
|
||||
}
|
||||
|
||||
proxyBox.Visible = false;
|
||||
|
||||
SetAllEnabled(false);
|
||||
ProxyVerifyBox.Visible = true; ProxyVerifyBox.Enabled = true;
|
||||
ProxyPwdBox.Enabled = true; SaveProxyBtn.Enabled = true;
|
||||
ProxyVerifyBox.Visible = true;
|
||||
ProxyVerifyBox.Enabled = true;
|
||||
ProxyPwdBox.Enabled = true;
|
||||
SaveProxyBtn.Enabled = true;
|
||||
ProxyVerifyBox.Select();
|
||||
}
|
||||
|
||||
@ -3043,13 +3048,11 @@ namespace NUS_Downloader
|
||||
{
|
||||
// Current directory...
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
// Check for Proxy Settings file...
|
||||
if (File.Exists(currentdir + "proxy.txt") == true)
|
||||
if (File.Exists(Path.Combine(currentdir, "proxy.txt")) == true)
|
||||
{
|
||||
string[] proxy_file = File.ReadAllLines(currentdir + "proxy.txt");
|
||||
string[] proxy_file = File.ReadAllLines(Path.Combine(currentdir, "proxy.txt"));
|
||||
|
||||
ProxyURL.Text = proxy_file[0];
|
||||
if (proxy_file.Length > 1)
|
||||
@ -3085,15 +3088,13 @@ namespace NUS_Downloader
|
||||
{
|
||||
// Current directory...
|
||||
string currentdir = Directory.GetCurrentDirectory();
|
||||
if (!(currentdir.EndsWith(Path.DirectorySeparatorChar.ToString())) || !(currentdir.EndsWith(Path.AltDirectorySeparatorChar.ToString())))
|
||||
currentdir += Path.DirectorySeparatorChar.ToString();
|
||||
|
||||
// Open a NUS script.
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Multiselect = false;
|
||||
ofd.Filter = "NUS Scripts|*.nus|All Files|*.*";
|
||||
if (Directory.Exists(currentdir + "scripts"))
|
||||
ofd.InitialDirectory = currentdir + "scripts";
|
||||
if (Directory.Exists(Path.Combine(currentdir, "scripts")))
|
||||
ofd.InitialDirectory = Path.Combine(currentdir, "scripts");
|
||||
ofd.Title = "Load a NUS/Wiimpersonator script.";
|
||||
|
||||
if (ofd.ShowDialog() != DialogResult.Cancel)
|
||||
@ -3136,8 +3137,14 @@ namespace NUS_Downloader
|
||||
if (string.IsNullOrEmpty(title_info[0]))
|
||||
break;
|
||||
titleidbox.Text = title_info[0];
|
||||
titleversion.Text = Convert.ToString(256*(byte.Parse(title_info[1].Substring(0, 2), System.Globalization.NumberStyles.HexNumber)));
|
||||
titleversion.Text = Convert.ToString(Convert.ToInt32(titleversion.Text) + byte.Parse(title_info[1].Substring(2, 2), System.Globalization.NumberStyles.HexNumber));
|
||||
titleversion.Text =
|
||||
Convert.ToString(256*
|
||||
(byte.Parse(title_info[1].Substring(0, 2),
|
||||
System.Globalization.NumberStyles.HexNumber)));
|
||||
titleversion.Text =
|
||||
Convert.ToString(Convert.ToInt32(titleversion.Text) +
|
||||
byte.Parse(title_info[1].Substring(2, 2),
|
||||
System.Globalization.NumberStyles.HexNumber));
|
||||
|
||||
button3_Click("Scripter", EventArgs.Empty);
|
||||
|
||||
@ -3191,14 +3198,14 @@ namespace NUS_Downloader
|
||||
|
||||
// Find our start point
|
||||
string startofcommonkey = "Common key (";
|
||||
keyspostsource = keyspostsource.Substring(keyspostsource.IndexOf(startofcommonkey) + startofcommonkey.Length, 32);
|
||||
keyspostsource = keyspostsource.Substring(
|
||||
keyspostsource.IndexOf(startofcommonkey) + startofcommonkey.Length, 32);
|
||||
WriteStatus("Got the common key as: " + keyspostsource);
|
||||
byte[] commonkey = HexStringToByteArray(keyspostsource);
|
||||
if (WriteCommonKey("key.bin", commonkey))
|
||||
{
|
||||
BootChecks();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static string ByteArrayToHexString(byte[] Bytes)
|
||||
@ -3218,9 +3225,12 @@ namespace NUS_Downloader
|
||||
public static byte[] HexStringToByteArray(string Hex)
|
||||
{
|
||||
byte[] Bytes = new byte[Hex.Length/2];
|
||||
int[] HexValue = new int[] { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
int[] HexValue = new int[]
|
||||
{
|
||||
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x0B, 0x0C, 0x0D,
|
||||
0x0E, 0x0F };
|
||||
0x0E, 0x0F
|
||||
};
|
||||
|
||||
for (int x = 0, i = 0; i < Hex.Length; i += 2, x += 1)
|
||||
{
|
||||
@ -3230,10 +3240,5 @@ namespace NUS_Downloader
|
||||
|
||||
return Bytes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user