mirror of
https://github.com/TheShadowEevee/libWiiSharp.git
synced 2025-01-11 15:38:51 -06:00
Finished fixing up some things
This commit is contained in:
parent
894dbce4ab
commit
7bb002918e
6 changed files with 85 additions and 87 deletions
18
Headers.cs
18
Headers.cs
|
@ -702,7 +702,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream(fileOrHeader);
|
||||
try
|
||||
{
|
||||
imD5.ParseHeader(memoryStream);
|
||||
imD5.PrivParseHeader(memoryStream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -726,7 +726,7 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
Headers.IMD5 imD5 = new Headers.IMD5();
|
||||
imD5.ParseHeader(fileOrHeader);
|
||||
imD5.PrivParseHeader(fileOrHeader);
|
||||
return imD5;
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ namespace libWiiSharp
|
|||
{
|
||||
fileSize = (uint)file.Length
|
||||
};
|
||||
imD5.ComputeHash(file);
|
||||
imD5.PrivComputeHash(file);
|
||||
return imD5;
|
||||
}
|
||||
|
||||
|
@ -767,7 +767,7 @@ namespace libWiiSharp
|
|||
Headers.IMD5 imD5 = Create(file);
|
||||
MemoryStream memoryStream1 = new MemoryStream();
|
||||
MemoryStream memoryStream2 = memoryStream1;
|
||||
imD5.WriteToStream(memoryStream2);
|
||||
imD5.PrivWriteToStream(memoryStream2);
|
||||
memoryStream1.Write(file, 0, file.Length);
|
||||
byte[] array = memoryStream1.ToArray();
|
||||
memoryStream1.Dispose();
|
||||
|
@ -809,7 +809,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream();
|
||||
try
|
||||
{
|
||||
WriteToStream(memoryStream);
|
||||
PrivWriteToStream(memoryStream);
|
||||
return memoryStream;
|
||||
}
|
||||
catch
|
||||
|
@ -834,12 +834,12 @@ namespace libWiiSharp
|
|||
/// <param name="writeStream"></param>
|
||||
public void Write(Stream writeStream)
|
||||
{
|
||||
WriteToStream(writeStream);
|
||||
PrivWriteToStream(writeStream);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
private void WriteToStream(Stream writeStream)
|
||||
private void PrivWriteToStream(Stream writeStream)
|
||||
{
|
||||
writeStream.Seek(0L, SeekOrigin.Begin);
|
||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(imd5Magic)), 0, 4);
|
||||
|
@ -848,14 +848,14 @@ namespace libWiiSharp
|
|||
writeStream.Write(hash, 0, hash.Length);
|
||||
}
|
||||
|
||||
private void ComputeHash(byte[] bytesToHash)
|
||||
private void PrivComputeHash(byte[] bytesToHash)
|
||||
{
|
||||
MD5 md5 = MD5.Create();
|
||||
hash = md5.ComputeHash(bytesToHash);
|
||||
md5.Clear();
|
||||
}
|
||||
|
||||
private void ParseHeader(Stream headerStream)
|
||||
private void PrivParseHeader(Stream headerStream)
|
||||
{
|
||||
headerStream.Seek(0L, SeekOrigin.Begin);
|
||||
byte[] buffer = new byte[4];
|
||||
|
|
72
HexView.cs
72
HexView.cs
|
@ -71,7 +71,7 @@ namespace libWiiSharp
|
|||
/// <returns></returns>
|
||||
public static string DumpAsString(byte[] data)
|
||||
{
|
||||
return string.Join("\n", DumpAsStringArray(data));
|
||||
return string.Join("\n", PrivDumpAsStringArray(data));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -101,9 +101,9 @@ namespace libWiiSharp
|
|||
|
||||
for (int index = 0; index < 16; ++index)
|
||||
{
|
||||
if (ToAscii(byte.Parse((string)dataGridView.Rows[e.RowIndex].Cells[index + 1].Value, NumberStyles.HexNumber)) != str[index])
|
||||
if (PrivToAscii(byte.Parse((string)dataGridView.Rows[e.RowIndex].Cells[index + 1].Value, NumberStyles.HexNumber)) != str[index])
|
||||
{
|
||||
dataGridView.Rows[e.RowIndex].Cells[index + 1].Value = FromAscii(str[index]).ToString("x2");
|
||||
dataGridView.Rows[e.RowIndex].Cells[index + 1].Value = PrivFromAscii(str[index]).ToString("x2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
int startIndex = int.Parse(dataGridView.Columns[e.ColumnIndex].HeaderText, NumberStyles.HexNumber);
|
||||
string str = ((string)dataGridView.Rows[e.RowIndex].Cells[17].Value).Remove(startIndex, 1).Insert(startIndex, ToAscii(byte.Parse((string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value, NumberStyles.HexNumber)).ToString());
|
||||
string str = ((string)dataGridView.Rows[e.RowIndex].Cells[17].Value).Remove(startIndex, 1).Insert(startIndex, PrivToAscii(byte.Parse((string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value, NumberStyles.HexNumber)).ToString());
|
||||
dataGridView.Rows[e.RowIndex].Cells[17].Value = str;
|
||||
if (((string)dataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex].Value).Length <= 2)
|
||||
{
|
||||
|
@ -152,7 +152,7 @@ namespace libWiiSharp
|
|||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
private static string[] DumpAsStringArray(byte[] data)
|
||||
private static string[] PrivDumpAsStringArray(byte[] data)
|
||||
{
|
||||
List<string> stringList = new List<string>();
|
||||
int num;
|
||||
|
@ -165,7 +165,7 @@ namespace libWiiSharp
|
|||
{
|
||||
str1 = str1 + data[num + index].ToString("x2") + " ";
|
||||
string str3 = str2;
|
||||
ascii = ToAscii(data[num + index]);
|
||||
ascii = PrivToAscii(data[num + index]);
|
||||
string str4 = ascii.ToString();
|
||||
str2 = str3 + str4;
|
||||
}
|
||||
|
@ -182,7 +182,7 @@ namespace libWiiSharp
|
|||
{
|
||||
str1 = str1 + data[num + index].ToString("x2") + " ";
|
||||
string str3 = str2;
|
||||
ascii = ToAscii(data[num + index]);
|
||||
ascii = PrivToAscii(data[num + index]);
|
||||
string str4 = ascii.ToString();
|
||||
str2 = str3 + str4;
|
||||
}
|
||||
|
@ -196,8 +196,7 @@ namespace libWiiSharp
|
|||
}
|
||||
return stringList.ToArray();
|
||||
}
|
||||
// Unused
|
||||
/*
|
||||
|
||||
/// <summary>
|
||||
/// Dumps a DataGridView back to a byte array.
|
||||
/// The DataGridView must have the right format.
|
||||
|
@ -205,7 +204,7 @@ namespace libWiiSharp
|
|||
/// </summary>
|
||||
/// <param name="dataGridView"></param>
|
||||
/// <returns></returns>
|
||||
private static byte[] DumpFromDataGridView(DataGridView dataGridView)
|
||||
private static byte[] PrivDumpFromDataGridView(DataGridView dataGridView)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -235,7 +234,7 @@ namespace libWiiSharp
|
|||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="dataGridView"></param>
|
||||
private static void DumpToDataGridView(byte[] data, DataGridView dataGridView)
|
||||
private static void PrivDumpToDataGridView(byte[] data, DataGridView dataGridView)
|
||||
{
|
||||
dataGridView.Columns.Clear();
|
||||
dataGridView.Rows.Clear();
|
||||
|
@ -244,59 +243,59 @@ namespace libWiiSharp
|
|||
{
|
||||
HeaderText = "Offset",
|
||||
Width = 80,
|
||||
CellTemplate = (DataGridViewCell)new DataGridViewTextBoxCell()
|
||||
CellTemplate = new DataGridViewTextBoxCell()
|
||||
});
|
||||
for (int index = 0; index < 16; ++index)
|
||||
dataGridView.Columns.Add(new DataGridViewColumn()
|
||||
{
|
||||
HeaderText = index.ToString("x1"),
|
||||
Width = 30,
|
||||
CellTemplate = (DataGridViewCell)new DataGridViewTextBoxCell()
|
||||
CellTemplate = new DataGridViewTextBoxCell()
|
||||
});
|
||||
dataGridView.Columns.Add(new DataGridViewColumn()
|
||||
{
|
||||
HeaderText = "Dump",
|
||||
Width = 125,
|
||||
CellTemplate = (DataGridViewCell)new DataGridViewTextBoxCell()
|
||||
CellTemplate = new DataGridViewTextBoxCell()
|
||||
});
|
||||
int num;
|
||||
for (num = 0; (double)(data.Length - num) / 16.0 >= 1.0; num += 16)
|
||||
for (num = 0; (data.Length - num) / 16.0 >= 1.0; num += 16)
|
||||
{
|
||||
DataGridViewRow dataGridViewRow = new DataGridViewRow();
|
||||
int index1 = dataGridViewRow.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index1].Value = (object)num.ToString("x8");
|
||||
int index1 = dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index1].Value = num.ToString("x8");
|
||||
dataGridViewRow.Cells[index1].ReadOnly = true;
|
||||
string empty = string.Empty;
|
||||
for (int index2 = 0; index2 < 16; ++index2)
|
||||
{
|
||||
int index3 = dataGridViewRow.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index3].Value = (object)data[num + index2].ToString("x2");
|
||||
empty += HexView.ToAscii(data[num + index2]).ToString();
|
||||
int index3 = dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index3].Value = data[num + index2].ToString("x2");
|
||||
empty += PrivToAscii(data[num + index2]).ToString();
|
||||
}
|
||||
int index4 = dataGridViewRow.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index4].Value = (object)empty;
|
||||
int index4 = dataGridViewRow.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow.Cells[index4].Value = empty;
|
||||
dataGridView.Rows.Add(dataGridViewRow);
|
||||
}
|
||||
if (data.Length <= num)
|
||||
return;
|
||||
DataGridViewRow dataGridViewRow1 = new DataGridViewRow();
|
||||
int index5 = dataGridViewRow1.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index5].Value = (object)num.ToString("x8");
|
||||
int index5 = dataGridViewRow1.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index5].Value = num.ToString("x8");
|
||||
dataGridViewRow1.Cells[index5].ReadOnly = true;
|
||||
string empty1 = string.Empty;
|
||||
for (int index1 = 0; index1 < 16; ++index1)
|
||||
{
|
||||
if (index1 < data.Length - num)
|
||||
{
|
||||
int index2 = dataGridViewRow1.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index2].Value = (object)data[num + index1].ToString("x2");
|
||||
empty1 += HexView.ToAscii(data[num + index1]).ToString();
|
||||
int index2 = dataGridViewRow1.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index2].Value = data[num + index1].ToString("x2");
|
||||
empty1 += PrivToAscii(data[num + index1]).ToString();
|
||||
}
|
||||
else
|
||||
dataGridViewRow1.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells.Add(new DataGridViewTextBoxCell());
|
||||
}
|
||||
int index6 = dataGridViewRow1.Cells.Add((DataGridViewCell)new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index6].Value = (object)empty1;
|
||||
int index6 = dataGridViewRow1.Cells.Add(new DataGridViewTextBoxCell());
|
||||
dataGridViewRow1.Cells[index6].Value = empty1;
|
||||
dataGridView.Rows.Add(dataGridViewRow1);
|
||||
}
|
||||
|
||||
|
@ -307,7 +306,7 @@ namespace libWiiSharp
|
|||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <param name="listView"></param>
|
||||
private static void DumpToListView(byte[] data, ListView listView)
|
||||
private static void PrivDumpToListView(byte[] data, ListView listView)
|
||||
{
|
||||
listView.Columns.Clear();
|
||||
listView.Items.Clear();
|
||||
|
@ -318,14 +317,14 @@ namespace libWiiSharp
|
|||
listView.Columns.Add(index.ToString("x1"), index.ToString("x1"), 30, HorizontalAlignment.Left, string.Empty);
|
||||
listView.Columns.Add("Dump", "Dump", 125, HorizontalAlignment.Left, string.Empty);
|
||||
int num;
|
||||
for (num = 0; (double)(data.Length - num) / 16.0 >= 1.0; num += 16)
|
||||
for (num = 0; (data.Length - num) / 16.0 >= 1.0; num += 16)
|
||||
{
|
||||
ListViewItem listViewItem = new ListViewItem(num.ToString("x8"));
|
||||
string empty = string.Empty;
|
||||
for (int index = 0; index < 16; ++index)
|
||||
{
|
||||
listViewItem.SubItems.Add(data[num + index].ToString("x2"));
|
||||
empty += HexView.ToAscii(data[num + index]).ToString();
|
||||
empty += PrivToAscii(data[num + index]).ToString();
|
||||
}
|
||||
listViewItem.SubItems.Add(empty);
|
||||
listView.Items.Add(listViewItem);
|
||||
|
@ -339,7 +338,7 @@ namespace libWiiSharp
|
|||
if (index < data.Length - num)
|
||||
{
|
||||
listViewItem1.SubItems.Add(data[num + index].ToString("x2"));
|
||||
empty1 += HexView.ToAscii(data[num + index]).ToString();
|
||||
empty1 += PrivToAscii(data[num + index]).ToString();
|
||||
}
|
||||
else
|
||||
listViewItem1.SubItems.Add(string.Empty);
|
||||
|
@ -347,15 +346,14 @@ namespace libWiiSharp
|
|||
listViewItem1.SubItems.Add(empty1);
|
||||
listView.Items.Add(listViewItem1);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
private static char ToAscii(byte value)
|
||||
private static char PrivToAscii(byte value)
|
||||
{
|
||||
return value >= 32 && value <= 126 ? (char)value : '.';
|
||||
}
|
||||
|
||||
private static byte FromAscii(char value)
|
||||
private static byte PrivFromAscii(char value)
|
||||
{
|
||||
return (byte)value;
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ namespace libWiiSharp
|
|||
public void LoadIOS(ref WAD iosWad)
|
||||
{
|
||||
wadFile = iosWad;
|
||||
GetEsIndex();
|
||||
PrivGetEsIndex();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -88,12 +88,12 @@ namespace libWiiSharp
|
|||
|
||||
public int PatchFakeSigning(ref byte[] esModule)
|
||||
{
|
||||
return PatchFakeSigning(ref esModule);
|
||||
return PrivPatchFakeSigning(ref esModule);
|
||||
}
|
||||
|
||||
public int PatchEsIdentify(ref byte[] esModule)
|
||||
{
|
||||
return PatchEsIdentify(ref esModule);
|
||||
return PrivPatchEsIdentify(ref esModule);
|
||||
}
|
||||
|
||||
public int PatchNandPermissions(ref byte[] esModule)
|
||||
|
@ -305,7 +305,7 @@ namespace libWiiSharp
|
|||
return num;
|
||||
}
|
||||
|
||||
private void GetEsIndex()
|
||||
private void PrivGetEsIndex()
|
||||
{
|
||||
FireDebug("Scanning for ES Module...");
|
||||
string str = "$IOSVersion:";
|
||||
|
|
18
Lz77.cs
18
Lz77.cs
|
@ -273,14 +273,14 @@ namespace libWiiSharp
|
|||
|
||||
private Stream PrivCompress(Stream inFile)
|
||||
{
|
||||
if (Lz77.IsLz77Compressed(inFile))
|
||||
if (IsLz77Compressed(inFile))
|
||||
return inFile;
|
||||
inFile.Seek(0L, SeekOrigin.Begin);
|
||||
int num1 = 0;
|
||||
int[] numArray1 = new int[17];
|
||||
uint num2 = (uint)(((int)Convert.ToUInt32(inFile.Length) << 8) + 16);
|
||||
MemoryStream memoryStream = new MemoryStream();
|
||||
memoryStream.Write(BitConverter.GetBytes(Shared.Swap(Lz77.lz77Magic)), 0, 4);
|
||||
memoryStream.Write(BitConverter.GetBytes(Shared.Swap(lz77Magic)), 0, 4);
|
||||
memoryStream.Write(BitConverter.GetBytes(num2), 0, 4);
|
||||
this.InitTree();
|
||||
numArray1[0] = 0;
|
||||
|
@ -306,7 +306,7 @@ namespace libWiiSharp
|
|||
if (this.matchLength <= 2)
|
||||
{
|
||||
this.matchLength = 1;
|
||||
numArray1[num3++] = (int)this.textBuffer[r];
|
||||
numArray1[num3++] = this.textBuffer[r];
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -314,12 +314,12 @@ namespace libWiiSharp
|
|||
int[] numArray2 = numArray1;
|
||||
int index1 = num3;
|
||||
int num7 = index1 + 1;
|
||||
int num8 = (int)(ushort)(r - this.matchPosition - 1 >> 8 & 15) | this.matchLength - 3 << 4;
|
||||
int num8 = (ushort)(r - this.matchPosition - 1 >> 8 & 15) | this.matchLength - 3 << 4;
|
||||
numArray2[index1] = num8;
|
||||
int[] numArray3 = numArray1;
|
||||
int index2 = num7;
|
||||
num3 = index2 + 1;
|
||||
int num9 = (int)(ushort)(r - this.matchPosition - 1 & (int)byte.MaxValue);
|
||||
int num9 = (ushort)(r - this.matchPosition - 1 & byte.MaxValue);
|
||||
numArray3[index2] = num9;
|
||||
}
|
||||
if ((num4 >>= 1) == 0)
|
||||
|
@ -363,9 +363,9 @@ namespace libWiiSharp
|
|||
if (num1 % 4 != 0)
|
||||
{
|
||||
for (int index = 0; index < 4 - num1 % 4; ++index)
|
||||
memoryStream.WriteByte((byte)0);
|
||||
memoryStream.WriteByte(0);
|
||||
}
|
||||
return (Stream)memoryStream;
|
||||
return memoryStream;
|
||||
}
|
||||
|
||||
private void InitTree()
|
||||
|
@ -378,7 +378,7 @@ namespace libWiiSharp
|
|||
private void InsertNode(int r)
|
||||
{
|
||||
int num1 = 1;
|
||||
int index = 4097 + (this.textBuffer[r] != ushort.MaxValue ? (int)this.textBuffer[r] : 0);
|
||||
int index = 4097 + (this.textBuffer[r] != ushort.MaxValue ? this.textBuffer[r] : 0);
|
||||
this.rightSon[r] = this.leftSon[r] = 4096;
|
||||
this.matchLength = 0;
|
||||
int num2;
|
||||
|
@ -407,7 +407,7 @@ namespace libWiiSharp
|
|||
index = this.leftSon[index];
|
||||
}
|
||||
num2 = 1;
|
||||
while (num2 < 18 && (num1 = (int)this.textBuffer[r + num2] - (int)this.textBuffer[index + num2]) == 0)
|
||||
while (num2 < 18 && (num1 = this.textBuffer[r + num2] - this.textBuffer[index + num2]) == 0)
|
||||
++num2;
|
||||
}
|
||||
while (num2 <= this.matchLength);
|
||||
|
|
20
NusClient.cs
20
NusClient.cs
|
@ -97,7 +97,7 @@ namespace libWiiSharp
|
|||
|
||||
public TMD DownloadTMD(string titleId, string titleVersion)
|
||||
{
|
||||
return titleId.Length == 16 ? DownloadTmd(titleId, titleVersion) : throw new Exception("Title ID must be 16 characters long!");
|
||||
return titleId.Length == 16 ? PrivDownloadTmd(titleId, titleVersion) : throw new Exception("Title ID must be 16 characters long!");
|
||||
}
|
||||
|
||||
public Ticket DownloadTicket(string titleId)
|
||||
|
@ -146,7 +146,7 @@ namespace libWiiSharp
|
|||
contentId = num.ToString("x8");
|
||||
FireDebug("Downloading Content (Content ID: {0}) of Title {1} v{2}...", contentId, titleId, string.IsNullOrEmpty(titleVersion) ? "[Latest]" : titleVersion);
|
||||
FireDebug(" Checking for Internet connection...");
|
||||
if (!CheckInet())
|
||||
if (!PrivCheckInet())
|
||||
{
|
||||
FireDebug(" Connection not found...");
|
||||
throw new Exception("You're not connected to the internet!");
|
||||
|
@ -201,7 +201,7 @@ namespace libWiiSharp
|
|||
byte[] content = wcNus.DownloadData(str2 + empty);
|
||||
FireProgress(80);
|
||||
FireDebug(" Decrypting Content...");
|
||||
byte[] array = DecryptContent(content, contentIndex, tik, tmd);
|
||||
byte[] array = PrivDecryptContent(content, contentIndex, tik, tmd);
|
||||
Array.Resize<byte>(ref array, (int)tmd.Contents[contentIndex].Size);
|
||||
if (!Shared.CompareByteArrays(SHA1.Create().ComputeHash(array), tmd.Contents[contentIndex].Hash))
|
||||
{
|
||||
|
@ -215,7 +215,7 @@ namespace libWiiSharp
|
|||
|
||||
private Ticket PrivDownloadTicket(string titleId)
|
||||
{
|
||||
if (!CheckInet())
|
||||
if (!PrivCheckInet())
|
||||
{
|
||||
throw new Exception("You're not connected to the internet!");
|
||||
}
|
||||
|
@ -226,9 +226,9 @@ namespace libWiiSharp
|
|||
return Ticket.Load(tikArray);
|
||||
}
|
||||
|
||||
private TMD DownloadTmd(string titleId, string titleVersion)
|
||||
private TMD PrivDownloadTmd(string titleId, string titleVersion)
|
||||
{
|
||||
if (!CheckInet())
|
||||
if (!PrivCheckInet())
|
||||
{
|
||||
throw new Exception("You're not connected to the internet!");
|
||||
}
|
||||
|
@ -286,7 +286,7 @@ namespace libWiiSharp
|
|||
flag3 = false;
|
||||
}
|
||||
FireDebug(" Checking for Internet connection...");
|
||||
if (!CheckInet())
|
||||
if (!PrivCheckInet())
|
||||
{
|
||||
FireDebug(" Connection not found...");
|
||||
throw new Exception("You're not connected to the internet!");
|
||||
|
@ -398,7 +398,7 @@ namespace libWiiSharp
|
|||
string str3 = outputDir;
|
||||
contentId = tmd.Contents[contentIndex].ContentID;
|
||||
string str4 = contentId.ToString("x8");
|
||||
byte[] array = DecryptContent(File.ReadAllBytes(str3 + str4), contentIndex, tik, tmd);
|
||||
byte[] array = PrivDecryptContent(File.ReadAllBytes(str3 + str4), contentIndex, tik, tmd);
|
||||
Array.Resize<byte>(ref array, (int)tmd.Contents[contentIndex].Size);
|
||||
if (!Shared.CompareByteArrays(shA1.ComputeHash(array), tmd.Contents[contentIndex].Hash))
|
||||
{
|
||||
|
@ -465,7 +465,7 @@ namespace libWiiSharp
|
|||
FireProgress(100);
|
||||
}
|
||||
|
||||
private byte[] DecryptContent(byte[] content, int contentIndex, Ticket tik, TMD tmd)
|
||||
private byte[] PrivDecryptContent(byte[] content, int contentIndex, Ticket tik, TMD tmd)
|
||||
{
|
||||
Array.Resize<byte>(ref content, Shared.AddPadding(content.Length, 16));
|
||||
byte[] titleKey = tik.TitleKey;
|
||||
|
@ -492,7 +492,7 @@ namespace libWiiSharp
|
|||
return buffer;
|
||||
}
|
||||
|
||||
private bool CheckInet()
|
||||
private bool PrivCheckInet()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
36
Ticket.cs
36
Ticket.cs
|
@ -100,7 +100,7 @@ namespace libWiiSharp
|
|||
return;
|
||||
}
|
||||
|
||||
ReDecryptTitleKey();
|
||||
PrivReDecryptTitleKey();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream(ticket);
|
||||
try
|
||||
{
|
||||
ticket1.ParseTicket(memoryStream);
|
||||
ticket1.PrivParseTicket(memoryStream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -171,7 +171,7 @@ namespace libWiiSharp
|
|||
public static Ticket Load(Stream ticket)
|
||||
{
|
||||
Ticket ticket1 = new Ticket();
|
||||
ticket1.ParseTicket(ticket);
|
||||
ticket1.PrivParseTicket(ticket);
|
||||
return ticket1;
|
||||
}
|
||||
|
||||
|
@ -185,7 +185,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream(ticket);
|
||||
try
|
||||
{
|
||||
ParseTicket(memoryStream);
|
||||
PrivParseTicket(memoryStream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -197,7 +197,7 @@ namespace libWiiSharp
|
|||
|
||||
public void LoadFile(Stream ticket)
|
||||
{
|
||||
ParseTicket(ticket);
|
||||
PrivParseTicket(ticket);
|
||||
}
|
||||
|
||||
public void Save(string savePath)
|
||||
|
@ -218,7 +218,7 @@ namespace libWiiSharp
|
|||
}
|
||||
|
||||
using FileStream fileStream = new FileStream(savePath, FileMode.Create);
|
||||
WriteToStream(fileStream);
|
||||
PrivWriteToStream(fileStream);
|
||||
}
|
||||
|
||||
public MemoryStream ToMemoryStream()
|
||||
|
@ -236,7 +236,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream();
|
||||
try
|
||||
{
|
||||
WriteToStream(memoryStream);
|
||||
PrivWriteToStream(memoryStream);
|
||||
return memoryStream;
|
||||
}
|
||||
catch
|
||||
|
@ -261,7 +261,7 @@ namespace libWiiSharp
|
|||
MemoryStream memoryStream = new MemoryStream();
|
||||
try
|
||||
{
|
||||
WriteToStream(memoryStream);
|
||||
PrivWriteToStream(memoryStream);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@ -290,7 +290,7 @@ namespace libWiiSharp
|
|||
encryptedTitleKey[index] = (byte)newTitleKey[index];
|
||||
}
|
||||
|
||||
DecryptTitleKey();
|
||||
PrivDecryptTitleKey();
|
||||
titleKeyChanged = true;
|
||||
reDecrypt = true;
|
||||
newEncryptedTitleKey = encryptedTitleKey;
|
||||
|
@ -299,7 +299,7 @@ namespace libWiiSharp
|
|||
public void SetTitleKey(byte[] newTitleKey)
|
||||
{
|
||||
encryptedTitleKey = newTitleKey.Length == 16 ? newTitleKey : throw new Exception("The title key must be 16 characters long!");
|
||||
DecryptTitleKey();
|
||||
PrivDecryptTitleKey();
|
||||
titleKeyChanged = true;
|
||||
reDecrypt = true;
|
||||
newEncryptedTitleKey = newTitleKey;
|
||||
|
@ -317,11 +317,11 @@ namespace libWiiSharp
|
|||
});
|
||||
}
|
||||
|
||||
private void WriteToStream(Stream writeStream)
|
||||
private void PrivWriteToStream(Stream writeStream)
|
||||
{
|
||||
FireDebug("Writing Ticket...");
|
||||
FireDebug(" Encrypting Title Key...");
|
||||
EncryptTitleKey();
|
||||
PrivEncryptTitleKey();
|
||||
FireDebug(" -> Decrypted Title Key: {0}", (object)Shared.ByteArrayToString(decryptedTitleKey));
|
||||
FireDebug(" -> Encrypted Title Key: {0}", (object)Shared.ByteArrayToString(encryptedTitleKey));
|
||||
if (fakeSign)
|
||||
|
@ -421,7 +421,7 @@ namespace libWiiSharp
|
|||
FireDebug("Writing Ticket Finished...");
|
||||
}
|
||||
|
||||
private void ParseTicket(Stream ticketFile)
|
||||
private void PrivParseTicket(Stream ticketFile)
|
||||
{
|
||||
FireDebug("Parsing Ticket...");
|
||||
ticketFile.Seek(0L, SeekOrigin.Begin);
|
||||
|
@ -478,13 +478,13 @@ namespace libWiiSharp
|
|||
FireDebug(" Reading Padding4... (Offset: 0x{0})", (object)ticketFile.Position.ToString("x8").ToUpper());
|
||||
ticketFile.Read(padding4, 0, padding4.Length);
|
||||
FireDebug(" Decrypting Title Key...");
|
||||
DecryptTitleKey();
|
||||
PrivDecryptTitleKey();
|
||||
FireDebug(" -> Encrypted Title Key: {0}", (object)Shared.ByteArrayToString(encryptedTitleKey));
|
||||
FireDebug(" -> Decrypted Title Key: {0}", (object)Shared.ByteArrayToString(decryptedTitleKey));
|
||||
FireDebug("Parsing Ticket Finished...");
|
||||
}
|
||||
|
||||
private void DecryptTitleKey()
|
||||
private void PrivDecryptTitleKey()
|
||||
{
|
||||
byte[] numArray = commonKeyIndex == 1 ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
|
||||
byte[] bytes = BitConverter.GetBytes(Shared.Swap(titleId));
|
||||
|
@ -508,7 +508,7 @@ namespace libWiiSharp
|
|||
rijndaelManaged.Clear();
|
||||
}
|
||||
|
||||
private void EncryptTitleKey()
|
||||
private void PrivEncryptTitleKey()
|
||||
{
|
||||
commonKeyIndex = newKeyIndex;
|
||||
byte[] numArray = commonKeyIndex == 1 ? CommonKey.GetKoreanKey() : CommonKey.GetStandardKey();
|
||||
|
@ -533,10 +533,10 @@ namespace libWiiSharp
|
|||
rijndaelManaged.Clear();
|
||||
}
|
||||
|
||||
private void ReDecryptTitleKey()
|
||||
private void PrivReDecryptTitleKey()
|
||||
{
|
||||
encryptedTitleKey = newEncryptedTitleKey;
|
||||
DecryptTitleKey();
|
||||
PrivDecryptTitleKey();
|
||||
}
|
||||
|
||||
private void FireDebug(string debugMessage, params object[] args)
|
||||
|
|
Loading…
Reference in a new issue