mirror of
https://github.com/TheShadowEevee/libWiiSharp.git
synced 2025-01-11 15:38:51 -06:00
Continue Formatting/Recommenting
This commit is contained in:
parent
fc1abe4c4c
commit
ff33cd3254
16 changed files with 1903 additions and 1535 deletions
22
CommonKey.cs
22
CommonKey.cs
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.CommonKey
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
// Decompiled with JetBrains decompiler
|
|
||||||
// Type: libWiiSharp.CommonKeyType
|
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
|
||||||
|
|
||||||
namespace libWiiSharp
|
|
||||||
{
|
|
||||||
public enum CommonKeyType : byte
|
|
||||||
{
|
|
||||||
Standard,
|
|
||||||
Korean,
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.ContentIndices
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
|
|
|
@ -1,16 +1,49 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.HbcTransmitter
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
public enum Protocol
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Will preconfigure all settings for HBC to 1.0.5 (HAXX).
|
||||||
|
/// </summary>
|
||||||
|
HAXX = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Will preconfigure all settings for HBC from 1.0.5 (JODI).
|
||||||
|
/// </summary>
|
||||||
|
JODI = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// Remember to define your custom settings.
|
||||||
|
/// </summary>
|
||||||
|
Custom = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HbcTransmitter can easily transmit files to the Homebrew Channel.
|
||||||
|
/// In order to use compression, you need zlib1.dll in the application directory.
|
||||||
|
/// </summary>
|
||||||
public class HbcTransmitter : IDisposable
|
public class HbcTransmitter : IDisposable
|
||||||
{
|
{
|
||||||
private int blocksize = 4096;
|
private int blocksize = 4096;
|
||||||
|
@ -28,24 +61,38 @@ namespace libWiiSharp
|
||||||
private int compressionRatio;
|
private int compressionRatio;
|
||||||
private bool isDisposed;
|
private bool isDisposed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the buffer that is used to transmit the data.
|
||||||
|
/// Default is 4 * 1024. If you're facing problems (freezes while transmitting), try a higher size.
|
||||||
|
/// </summary>
|
||||||
public int Blocksize
|
public int Blocksize
|
||||||
{
|
{
|
||||||
get => this.blocksize;
|
get => this.blocksize;
|
||||||
set => this.blocksize = value;
|
set => this.blocksize = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mayor version of wiiload. You might need to change it for upcoming releases of the HBC.
|
||||||
|
/// </summary>
|
||||||
public int WiiloadVersionMayor
|
public int WiiloadVersionMayor
|
||||||
{
|
{
|
||||||
get => this.wiiloadMayor;
|
get => this.wiiloadMayor;
|
||||||
set => this.wiiloadMayor = value;
|
set => this.wiiloadMayor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The minor version of wiiload. You might need to change it for upcoming releases of the HBC.
|
||||||
|
/// </summary>
|
||||||
public int WiiloadVersionMinor
|
public int WiiloadVersionMinor
|
||||||
{
|
{
|
||||||
get => this.wiiloadMinor;
|
get => this.wiiloadMinor;
|
||||||
set => this.wiiloadMinor = value;
|
set => this.wiiloadMinor = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If true, the data will be compressed before being transmitted. NOT available for Protocol.HAXX!
|
||||||
|
/// Also, compression will only work if zlib1.dll is in the application folder.
|
||||||
|
/// </summary>
|
||||||
public bool Compress
|
public bool Compress
|
||||||
{
|
{
|
||||||
get => this.compress;
|
get => this.compress;
|
||||||
|
@ -57,28 +104,40 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The IP address of the Wii.
|
||||||
|
/// </summary>
|
||||||
public string IpAddress
|
public string IpAddress
|
||||||
{
|
{
|
||||||
get => this.ipAddress;
|
get => this.ipAddress;
|
||||||
set => this.ipAddress = value;
|
set => this.ipAddress = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The port used for the transmission.
|
||||||
|
/// You don't need to touch this unless the port changes in future releases of the HBC.
|
||||||
|
/// </summary>
|
||||||
public int Port
|
public int Port
|
||||||
{
|
{
|
||||||
get => this.port;
|
get => this.port;
|
||||||
set => this.port = value;
|
set => this.port = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After a successfully completed transmission, this value holds the number of transmitted bytes.
|
||||||
|
/// </summary>
|
||||||
public int TransmittedLength => this.transmittedLength;
|
public int TransmittedLength => this.transmittedLength;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// After a successfully completed transmission, this value holds the compression ratio.
|
||||||
|
/// Will be 0 if the data wasn't compressed.
|
||||||
|
/// </summary>
|
||||||
public int CompressionRatio => this.compressionRatio;
|
public int CompressionRatio => this.compressionRatio;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Holds the last occured error message.
|
||||||
|
/// </summary>
|
||||||
public string LastError => this.lastError;
|
public string LastError => this.lastError;
|
||||||
|
|
||||||
public event EventHandler<ProgressChangedEventArgs> Progress;
|
|
||||||
|
|
||||||
public event EventHandler<MessageEventArgs> Debug;
|
|
||||||
|
|
||||||
public HbcTransmitter(Protocol protocol, string ipAddress)
|
public HbcTransmitter(Protocol protocol, string ipAddress)
|
||||||
{
|
{
|
||||||
this.protocol = protocol;
|
this.protocol = protocol;
|
||||||
|
@ -87,6 +146,8 @@ namespace libWiiSharp
|
||||||
this.compress = protocol == Protocol.JODI;
|
this.compress = protocol == Protocol.JODI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region IDisposable Members
|
||||||
|
|
||||||
~HbcTransmitter() => this.Dispose(false);
|
~HbcTransmitter() => this.Dispose(false);
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
@ -115,11 +176,15 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
this.isDisposed = true;
|
this.isDisposed = true;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
public bool TransmitFile(string pathToFile) => this.transmit(Path.GetFileName(pathToFile), File.ReadAllBytes(pathToFile));
|
public bool TransmitFile(string pathToFile) => this.transmit(Path.GetFileName(pathToFile), File.ReadAllBytes(pathToFile));
|
||||||
|
|
||||||
public bool TransmitFile(string fileName, byte[] fileData) => this.transmit(fileName, fileData);
|
public bool TransmitFile(string fileName, byte[] fileData) => this.transmit(fileName, fileData);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
private bool transmit(string fileName, byte[] fileData)
|
private bool transmit(string fileName, byte[] fileData)
|
||||||
{
|
{
|
||||||
this.fireDebug("Transmitting {0} to {1}:{2}...", (object) fileName, (object) this.ipAddress, (object) this.port);
|
this.fireDebug("Transmitting {0} to {1}:{2}...", (object) fileName, (object) this.ipAddress, (object) this.port);
|
||||||
|
@ -281,6 +346,18 @@ namespace libWiiSharp
|
||||||
this.fireDebug("Transmitting {0} to {1}:{2} Finished...", (object) fileName, (object) this.ipAddress, (object) this.port);
|
this.fireDebug("Transmitting {0} to {1}:{2} Finished...", (object) fileName, (object) this.ipAddress, (object) this.port);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
/// <summary>
|
||||||
|
/// Fires the Progress of various operations
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<ProgressChangedEventArgs> Progress;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fires debugging messages. You may write them into a log file or log textbox.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<MessageEventArgs> Debug;
|
||||||
|
|
||||||
private void fireDebug(string debugMessage, params object[] args)
|
private void fireDebug(string debugMessage, params object[] args)
|
||||||
{
|
{
|
||||||
|
@ -297,5 +374,42 @@ namespace libWiiSharp
|
||||||
return;
|
return;
|
||||||
progress(new object(), new ProgressChangedEventArgs(progressPercentage, (object) string.Empty));
|
progress(new object(), new ProgressChangedEventArgs(progressPercentage, (object) string.Empty));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class zlibWrapper
|
||||||
|
{
|
||||||
|
[DllImport("zlib1.dll")]
|
||||||
|
private static extern zlibWrapper.ZLibError compress2(
|
||||||
|
byte[] dest,
|
||||||
|
ref int destLength,
|
||||||
|
byte[] source,
|
||||||
|
int sourceLength,
|
||||||
|
int level);
|
||||||
|
|
||||||
|
public static byte[] Compress(byte[] inFile)
|
||||||
|
{
|
||||||
|
byte[] array = new byte[inFile.Length + 64];
|
||||||
|
int destLength = -1;
|
||||||
|
zlibWrapper.ZLibError zlibError = zlibWrapper.compress2(array, ref destLength, inFile, inFile.Length, 6);
|
||||||
|
if (zlibError != zlibWrapper.ZLibError.Z_OK || destLength <= -1 || destLength >= inFile.Length)
|
||||||
|
throw new Exception("An error occured while compressing! Code: " + zlibError.ToString());
|
||||||
|
Array.Resize<byte>(ref array, destLength);
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ZLibError
|
||||||
|
{
|
||||||
|
Z_VERSION_ERROR = -6, // 0xFFFFFFFA
|
||||||
|
Z_BUF_ERROR = -5, // 0xFFFFFFFB
|
||||||
|
Z_MEM_ERROR = -4, // 0xFFFFFFFC
|
||||||
|
Z_DATA_ERROR = -3, // 0xFFFFFFFD
|
||||||
|
Z_STREAM_ERROR = -2, // 0xFFFFFFFE
|
||||||
|
Z_ERRNO = -1, // 0xFFFFFFFF
|
||||||
|
Z_OK = 0,
|
||||||
|
Z_STREAM_END = 1,
|
||||||
|
Z_NEED_DICT = 2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
230
Headers.cs
230
Headers.cs
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.Headers
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
@ -15,8 +27,39 @@ namespace libWiiSharp
|
||||||
private static uint imd5Magic = 1229800501;
|
private static uint imd5Magic = 1229800501;
|
||||||
private static uint imetMagic = 1229800788;
|
private static uint imetMagic = 1229800788;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Convert HeaderType to int to get it's Length.
|
||||||
|
/// </summary>
|
||||||
|
public enum HeaderType
|
||||||
|
{
|
||||||
|
None = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// Used in banner.bin / icon.bin
|
||||||
|
/// </summary>
|
||||||
|
IMD5 = 32,
|
||||||
|
/// <summary>
|
||||||
|
/// Used in opening.bnr
|
||||||
|
/// </summary>
|
||||||
|
ShortIMET = 1536,
|
||||||
|
/// <summary>
|
||||||
|
/// Used in 00000000.app
|
||||||
|
/// </summary>
|
||||||
|
IMET = 1600,
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
|
/// <summary>
|
||||||
|
/// Checks a file for Headers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.HeaderType DetectHeader(string pathToFile) => Headers.DetectHeader(File.ReadAllBytes(pathToFile));
|
public static Headers.HeaderType DetectHeader(string pathToFile) => Headers.DetectHeader(File.ReadAllBytes(pathToFile));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the byte array for Headers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.HeaderType DetectHeader(byte[] file)
|
public static Headers.HeaderType DetectHeader(byte[] file)
|
||||||
{
|
{
|
||||||
if (file.Length > 68 && (int) Shared.Swap(BitConverter.ToUInt32(file, 64)) == (int) Headers.imetMagic)
|
if (file.Length > 68 && (int) Shared.Swap(BitConverter.ToUInt32(file, 64)) == (int) Headers.imetMagic)
|
||||||
|
@ -26,6 +69,11 @@ namespace libWiiSharp
|
||||||
return file.Length > 4 && (int) Shared.Swap(BitConverter.ToUInt32(file, 0)) == (int) Headers.imd5Magic ? Headers.HeaderType.IMD5 : Headers.HeaderType.None;
|
return file.Length > 4 && (int) Shared.Swap(BitConverter.ToUInt32(file, 0)) == (int) Headers.imd5Magic ? Headers.HeaderType.IMD5 : Headers.HeaderType.None;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks the stream for Headers.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.HeaderType DetectHeader(Stream file)
|
public static Headers.HeaderType DetectHeader(Stream file)
|
||||||
{
|
{
|
||||||
byte[] buffer = new byte[4];
|
byte[] buffer = new byte[4];
|
||||||
|
@ -52,14 +100,7 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
return Headers.HeaderType.None;
|
return Headers.HeaderType.None;
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
public enum HeaderType
|
|
||||||
{
|
|
||||||
None = 0,
|
|
||||||
IMD5 = 32, // 0x00000020
|
|
||||||
ShortIMET = 1536, // 0x00000600
|
|
||||||
IMET = 1600, // 0x00000640
|
|
||||||
}
|
|
||||||
|
|
||||||
public class IMET
|
public class IMET
|
||||||
{
|
{
|
||||||
|
@ -87,78 +128,117 @@ namespace libWiiSharp
|
||||||
private byte[] padding2 = new byte[588];
|
private byte[] padding2 = new byte[588];
|
||||||
private byte[] hash = new byte[16];
|
private byte[] hash = new byte[16];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Short IMET has a padding of 64 bytes at the beginning while Long IMET has 128.
|
||||||
|
/// </summary>
|
||||||
public bool IsShortIMET
|
public bool IsShortIMET
|
||||||
{
|
{
|
||||||
get => this.isShortImet;
|
get => this.isShortImet;
|
||||||
set => this.isShortImet = value;
|
set => this.isShortImet = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of uncompressed icon.bin
|
||||||
|
/// </summary>
|
||||||
public uint IconSize
|
public uint IconSize
|
||||||
{
|
{
|
||||||
get => this.iconSize;
|
get => this.iconSize;
|
||||||
set => this.iconSize = value;
|
set => this.iconSize = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of uncompressed banner.bin
|
||||||
|
/// </summary>
|
||||||
public uint BannerSize
|
public uint BannerSize
|
||||||
{
|
{
|
||||||
get => this.bannerSize;
|
get => this.bannerSize;
|
||||||
set => this.bannerSize = value;
|
set => this.bannerSize = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of uncompressed sound.bin
|
||||||
|
/// </summary>
|
||||||
public uint SoundSize
|
public uint SoundSize
|
||||||
{
|
{
|
||||||
get => this.soundSize;
|
get => this.soundSize;
|
||||||
set => this.soundSize = value;
|
set => this.soundSize = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Japanese Title.
|
||||||
|
/// </summary>
|
||||||
public string JapaneseTitle
|
public string JapaneseTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.japaneseTitle);
|
get => this.returnTitleAsString(this.japaneseTitle);
|
||||||
set => this.setTitleFromString(value, 0);
|
set => this.setTitleFromString(value, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The English Title.
|
||||||
|
/// </summary>
|
||||||
public string EnglishTitle
|
public string EnglishTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.englishTitle);
|
get => this.returnTitleAsString(this.englishTitle);
|
||||||
set => this.setTitleFromString(value, 1);
|
set => this.setTitleFromString(value, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The German Title.
|
||||||
|
/// </summary>
|
||||||
public string GermanTitle
|
public string GermanTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.germanTitle);
|
get => this.returnTitleAsString(this.germanTitle);
|
||||||
set => this.setTitleFromString(value, 2);
|
set => this.setTitleFromString(value, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The French Title.
|
||||||
|
/// </summary>
|
||||||
public string FrenchTitle
|
public string FrenchTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.frenchTitle);
|
get => this.returnTitleAsString(this.frenchTitle);
|
||||||
set => this.setTitleFromString(value, 3);
|
set => this.setTitleFromString(value, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Spanish Title.
|
||||||
|
/// </summary>
|
||||||
public string SpanishTitle
|
public string SpanishTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.spanishTitle);
|
get => this.returnTitleAsString(this.spanishTitle);
|
||||||
set => this.setTitleFromString(value, 4);
|
set => this.setTitleFromString(value, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Italian Title.
|
||||||
|
/// </summary>
|
||||||
public string ItalianTitle
|
public string ItalianTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.italianTitle);
|
get => this.returnTitleAsString(this.italianTitle);
|
||||||
set => this.setTitleFromString(value, 5);
|
set => this.setTitleFromString(value, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Dutch Title.
|
||||||
|
/// </summary>
|
||||||
public string DutchTitle
|
public string DutchTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.dutchTitle);
|
get => this.returnTitleAsString(this.dutchTitle);
|
||||||
set => this.setTitleFromString(value, 6);
|
set => this.setTitleFromString(value, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The Korean Title.
|
||||||
|
/// </summary>
|
||||||
public string KoreanTitle
|
public string KoreanTitle
|
||||||
{
|
{
|
||||||
get => this.returnTitleAsString(this.koreanTitle);
|
get => this.returnTitleAsString(this.koreanTitle);
|
||||||
set => this.setTitleFromString(value, 7);
|
set => this.setTitleFromString(value, 7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All Titles as a string array.
|
||||||
|
/// </summary>
|
||||||
public string[] AllTitles => new string[8]
|
public string[] AllTitles => new string[8]
|
||||||
{
|
{
|
||||||
this.JapaneseTitle,
|
this.JapaneseTitle,
|
||||||
|
@ -171,10 +251,24 @@ namespace libWiiSharp
|
||||||
this.KoreanTitle
|
this.KoreanTitle
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// When parsing an IMET header, this value will turn false if the hash stored in the header doesn't match the headers hash.
|
||||||
|
/// </summary>
|
||||||
public bool HashesMatch => this.hashesMatch;
|
public bool HashesMatch => this.hashesMatch;
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMET Header of a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMET Load(string pathToFile) => Headers.IMET.Load(File.ReadAllBytes(pathToFile));
|
public static Headers.IMET Load(string pathToFile) => Headers.IMET.Load(File.ReadAllBytes(pathToFile));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMET Header of a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileOrHeader"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMET Load(byte[] fileOrHeader)
|
public static Headers.IMET Load(byte[] fileOrHeader)
|
||||||
{
|
{
|
||||||
Headers.HeaderType headerType = Headers.DetectHeader(fileOrHeader);
|
Headers.HeaderType headerType = Headers.DetectHeader(fileOrHeader);
|
||||||
|
@ -202,6 +296,11 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMET Header of a stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileOrHeader"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMET Load(Stream fileOrHeader)
|
public static Headers.IMET Load(Stream fileOrHeader)
|
||||||
{
|
{
|
||||||
Headers.HeaderType headerType = Headers.DetectHeader(fileOrHeader);
|
Headers.HeaderType headerType = Headers.DetectHeader(fileOrHeader);
|
||||||
|
@ -219,6 +318,15 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new IMET Header.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="isShortImet"></param>
|
||||||
|
/// <param name="iconSize"></param>
|
||||||
|
/// <param name="bannerSize"></param>
|
||||||
|
/// <param name="soundSize"></param>
|
||||||
|
/// <param name="titles"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMET Create(
|
public static Headers.IMET Create(
|
||||||
bool isShortImet,
|
bool isShortImet,
|
||||||
int iconSize,
|
int iconSize,
|
||||||
|
@ -238,6 +346,10 @@ namespace libWiiSharp
|
||||||
return imet;
|
return imet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the IMET Header of a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
public static void RemoveHeader(string pathToFile)
|
public static void RemoveHeader(string pathToFile)
|
||||||
{
|
{
|
||||||
byte[] bytes = Headers.IMET.RemoveHeader(File.ReadAllBytes(pathToFile));
|
byte[] bytes = Headers.IMET.RemoveHeader(File.ReadAllBytes(pathToFile));
|
||||||
|
@ -245,6 +357,11 @@ namespace libWiiSharp
|
||||||
File.WriteAllBytes(pathToFile, bytes);
|
File.WriteAllBytes(pathToFile, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the IMET Header of a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static byte[] RemoveHeader(byte[] file)
|
public static byte[] RemoveHeader(byte[] file)
|
||||||
{
|
{
|
||||||
Headers.HeaderType headerType = Headers.DetectHeader(file);
|
Headers.HeaderType headerType = Headers.DetectHeader(file);
|
||||||
|
@ -260,12 +377,20 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets all title to the given string.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newTitle"></param>
|
||||||
public void SetAllTitles(string newTitle)
|
public void SetAllTitles(string newTitle)
|
||||||
{
|
{
|
||||||
for (int titleIndex = 0; titleIndex < 10; ++titleIndex)
|
for (int titleIndex = 0; titleIndex < 10; ++titleIndex)
|
||||||
this.setTitleFromString(newTitle, titleIndex);
|
this.setTitleFromString(newTitle, titleIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Header as a memory stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public MemoryStream ToMemoryStream()
|
public MemoryStream ToMemoryStream()
|
||||||
{
|
{
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
@ -281,10 +406,22 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the Header as a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public byte[] ToByteArray() => this.ToMemoryStream().ToArray();
|
public byte[] ToByteArray() => this.ToMemoryStream().ToArray();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the Header to the given stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writeStream"></param>
|
||||||
public void Write(Stream writeStream) => this.writeToStream(writeStream);
|
public void Write(Stream writeStream) => this.writeToStream(writeStream);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Changes the Titles.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newTitles"></param>
|
||||||
public void ChangeTitles(params string[] newTitles)
|
public void ChangeTitles(params string[] newTitles)
|
||||||
{
|
{
|
||||||
for (int titleIndex = 0; titleIndex < newTitles.Length; ++titleIndex)
|
for (int titleIndex = 0; titleIndex < newTitles.Length; ++titleIndex)
|
||||||
|
@ -293,6 +430,10 @@ namespace libWiiSharp
|
||||||
this.setTitleFromString(newTitles.Length > 1 ? newTitles[1] : newTitles[0], length);
|
this.setTitleFromString(newTitles.Length > 1 ? newTitles[1] : newTitles[0], length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns a string array with the Titles.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public string[] GetTitles() => new string[8]
|
public string[] GetTitles() => new string[8]
|
||||||
{
|
{
|
||||||
this.JapaneseTitle,
|
this.JapaneseTitle,
|
||||||
|
@ -304,7 +445,9 @@ namespace libWiiSharp
|
||||||
this.DutchTitle,
|
this.DutchTitle,
|
||||||
this.KoreanTitle
|
this.KoreanTitle
|
||||||
};
|
};
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
private void writeToStream(Stream writeStream)
|
private void writeToStream(Stream writeStream)
|
||||||
{
|
{
|
||||||
writeStream.Seek(0L, SeekOrigin.Begin);
|
writeStream.Seek(0L, SeekOrigin.Begin);
|
||||||
|
@ -446,6 +589,7 @@ namespace libWiiSharp
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
public class IMD5
|
public class IMD5
|
||||||
|
@ -455,16 +599,33 @@ namespace libWiiSharp
|
||||||
private byte[] padding = new byte[8];
|
private byte[] padding = new byte[8];
|
||||||
private byte[] hash = new byte[16];
|
private byte[] hash = new byte[16];
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The size of the file without the IMD5 Header.
|
||||||
|
/// </summary>
|
||||||
public uint FileSize => this.fileSize;
|
public uint FileSize => this.fileSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The hash of the file without the IMD5 Header.
|
||||||
|
/// </summary>
|
||||||
public byte[] Hash => this.hash;
|
public byte[] Hash => this.hash;
|
||||||
|
|
||||||
private IMD5()
|
private IMD5()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMD5 Header of a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMD5 Load(string pathToFile) => Headers.IMD5.Load(File.ReadAllBytes(pathToFile));
|
public static Headers.IMD5 Load(string pathToFile) => Headers.IMD5.Load(File.ReadAllBytes(pathToFile));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMD5 Header of a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileOrHeader"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMD5 Load(byte[] fileOrHeader)
|
public static Headers.IMD5 Load(byte[] fileOrHeader)
|
||||||
{
|
{
|
||||||
if (Headers.DetectHeader(fileOrHeader) != Headers.HeaderType.IMD5)
|
if (Headers.DetectHeader(fileOrHeader) != Headers.HeaderType.IMD5)
|
||||||
|
@ -484,6 +645,11 @@ namespace libWiiSharp
|
||||||
return imD5;
|
return imD5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Loads the IMD5 Header of a stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileOrHeader"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMD5 Load(Stream fileOrHeader)
|
public static Headers.IMD5 Load(Stream fileOrHeader)
|
||||||
{
|
{
|
||||||
if (Headers.DetectHeader(fileOrHeader) != Headers.HeaderType.IMD5)
|
if (Headers.DetectHeader(fileOrHeader) != Headers.HeaderType.IMD5)
|
||||||
|
@ -493,6 +659,11 @@ namespace libWiiSharp
|
||||||
return imD5;
|
return imD5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Creates a new IMD5 Header.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static Headers.IMD5 Create(byte[] file)
|
public static Headers.IMD5 Create(byte[] file)
|
||||||
{
|
{
|
||||||
Headers.IMD5 imD5 = new Headers.IMD5();
|
Headers.IMD5 imD5 = new Headers.IMD5();
|
||||||
|
@ -501,6 +672,10 @@ namespace libWiiSharp
|
||||||
return imD5;
|
return imD5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an IMD5 Header to a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
public static void AddHeader(string pathToFile)
|
public static void AddHeader(string pathToFile)
|
||||||
{
|
{
|
||||||
byte[] buffer = Headers.IMD5.AddHeader(File.ReadAllBytes(pathToFile));
|
byte[] buffer = Headers.IMD5.AddHeader(File.ReadAllBytes(pathToFile));
|
||||||
|
@ -509,6 +684,11 @@ namespace libWiiSharp
|
||||||
fileStream.Write(buffer, 0, buffer.Length);
|
fileStream.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Adds an IMD5 Header to a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static byte[] AddHeader(byte[] file)
|
public static byte[] AddHeader(byte[] file)
|
||||||
{
|
{
|
||||||
Headers.IMD5 imD5 = Headers.IMD5.Create(file);
|
Headers.IMD5 imD5 = Headers.IMD5.Create(file);
|
||||||
|
@ -521,6 +701,10 @@ namespace libWiiSharp
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the IMD5 Header of a file.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pathToFile"></param>
|
||||||
public static void RemoveHeader(string pathToFile)
|
public static void RemoveHeader(string pathToFile)
|
||||||
{
|
{
|
||||||
byte[] buffer = Headers.IMD5.RemoveHeader(File.ReadAllBytes(pathToFile));
|
byte[] buffer = Headers.IMD5.RemoveHeader(File.ReadAllBytes(pathToFile));
|
||||||
|
@ -529,6 +713,11 @@ namespace libWiiSharp
|
||||||
fileStream.Write(buffer, 0, buffer.Length);
|
fileStream.Write(buffer, 0, buffer.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes the IMD5 Header of a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static byte[] RemoveHeader(byte[] file)
|
public static byte[] RemoveHeader(byte[] file)
|
||||||
{
|
{
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
@ -538,6 +727,10 @@ namespace libWiiSharp
|
||||||
return array;
|
return array;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the IMD5 Header as a memory stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public MemoryStream ToMemoryStream()
|
public MemoryStream ToMemoryStream()
|
||||||
{
|
{
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
@ -553,10 +746,20 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the IMD5 Header as a byte array.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public byte[] ToByteArray() => this.ToMemoryStream().ToArray();
|
public byte[] ToByteArray() => this.ToMemoryStream().ToArray();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the IMD5 Header to the given stream.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="writeStream"></param>
|
||||||
public void Write(Stream writeStream) => this.writeToStream(writeStream);
|
public void Write(Stream writeStream) => this.writeToStream(writeStream);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
private void writeToStream(Stream writeStream)
|
private void writeToStream(Stream writeStream)
|
||||||
{
|
{
|
||||||
writeStream.Seek(0L, SeekOrigin.Begin);
|
writeStream.Seek(0L, SeekOrigin.Begin);
|
||||||
|
@ -585,6 +788,7 @@ namespace libWiiSharp
|
||||||
headerStream.Read(this.padding, 0, this.padding.Length);
|
headerStream.Read(this.padding, 0, this.padding.Length);
|
||||||
headerStream.Read(this.hash, 0, this.hash.Length);
|
headerStream.Read(this.hash, 0, this.hash.Length);
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
92
HexView.cs
92
HexView.cs
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.HexView
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
@ -12,16 +24,49 @@ using System.Windows.Forms;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A static class that provides functions to dump a byte array to view it like in a hex-editor.
|
||||||
|
/// In combination with a DataGridView, it's even able to act like a hex-editor.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
public static class HexView
|
public static class HexView
|
||||||
{
|
{
|
||||||
private static string savedValue;
|
private static string savedValue;
|
||||||
|
|
||||||
|
#region Public Functions
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor in a ListView.
|
||||||
|
/// Columns will be created, estimated width is ~685 px.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="listView"></param>
|
||||||
public static void DumpToListView(byte[] data, ListView listView) => HexView.dumpToListView(data, listView);
|
public static void DumpToListView(byte[] data, ListView listView) => HexView.dumpToListView(data, listView);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor in a DataGridView.
|
||||||
|
/// Columns will be created, estimated width is ~685 px.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="dataGridView"></param>
|
||||||
public static void DumpToDataGridView(byte[] data, DataGridView dataGridView) => HexView.dumpToDataGridView(data, dataGridView);
|
public static void DumpToDataGridView(byte[] data, DataGridView dataGridView) => HexView.dumpToDataGridView(data, dataGridView);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Dumps a DataGridView back to a byte array.
|
||||||
|
/// The DataGridView must have the right format.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dataGridView"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static byte[] DumpFromDataGridView(DataGridView dataGridView) => HexView.dumpFromDataGridView(dataGridView);
|
public static byte[] DumpFromDataGridView(DataGridView dataGridView) => HexView.dumpFromDataGridView(dataGridView);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor in a RichTextBox.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="richTextBox"></param>
|
||||||
public static void DumpToRichTextBox(byte[] data, RichTextBox richTextBox)
|
public static void DumpToRichTextBox(byte[] data, RichTextBox richTextBox)
|
||||||
{
|
{
|
||||||
richTextBox.Clear();
|
richTextBox.Clear();
|
||||||
|
@ -30,6 +75,12 @@ namespace libWiiSharp
|
||||||
richTextBox.Text = HexView.DumpAsString(data);
|
richTextBox.Text = HexView.DumpAsString(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor in a TextBox.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <param name="textBox"></param>
|
||||||
public static void DumpToTextBox(byte[] data, TextBox textBox)
|
public static void DumpToTextBox(byte[] data, TextBox textBox)
|
||||||
{
|
{
|
||||||
textBox.Multiline = true;
|
textBox.Multiline = true;
|
||||||
|
@ -38,10 +89,31 @@ namespace libWiiSharp
|
||||||
textBox.Text = HexView.DumpAsString(data).Replace("\n", "\r\n");
|
textBox.Text = HexView.DumpAsString(data).Replace("\n", "\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor as a string array.
|
||||||
|
/// Be sure to use "Courier New" as a font, so every char has the same width.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string[] DumpAsStringArray(byte[] data) => HexView.dumpAsStringArray(data);
|
public static string[] DumpAsStringArray(byte[] data) => HexView.dumpAsStringArray(data);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Displays the byte array like a hex editor as a string.
|
||||||
|
/// Be sure to use "Courier New" as a font, so every char has the same width.
|
||||||
|
/// Big files (25kB ++) will take quite a long time, so don't use this for big files.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
public static string DumpAsString(byte[] data) => string.Join("\n", HexView.dumpAsStringArray(data));
|
public static string DumpAsString(byte[] data) => string.Join("\n", HexView.dumpAsStringArray(data));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Link your DataGridView's CellEndEdit event with this function.
|
||||||
|
/// The dump and byte values will be synchronized.
|
||||||
|
/// Don't forget to also link the CellBeginEdit event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
public static void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
public static void DataGridView_CellEndEdit(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -78,8 +150,17 @@ namespace libWiiSharp
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Link your DataGridView's CellBeginEdit event with this function.
|
||||||
|
/// The dump and byte values will be synchronized.
|
||||||
|
/// Don't forget to also link the CellEndEdit event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
public static void DataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) => HexView.savedValue = (string) ((DataGridView) sender).Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
public static void DataGridView_CellBeginEdit(object sender, DataGridViewCellCancelEventArgs e) => HexView.savedValue = (string) ((DataGridView) sender).Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
private static string[] dumpAsStringArray(byte[] data)
|
private static string[] dumpAsStringArray(byte[] data)
|
||||||
{
|
{
|
||||||
List<string> stringList = new List<string>();
|
List<string> stringList = new List<string>();
|
||||||
|
@ -256,5 +337,6 @@ namespace libWiiSharp
|
||||||
private static char toAscii(byte value) => value >= (byte) 32 && value <= (byte) 126 ? (char) value : '.';
|
private static char toAscii(byte value) => value >= (byte) 32 && value <= (byte) 126 ? (char) value : '.';
|
||||||
|
|
||||||
private static byte fromAscii(char value) => (byte) value;
|
private static byte fromAscii(char value) => (byte) value;
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.IosPatcher
|
* Copyright (C) 2009 Leathl
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
* Copyright (C) 2020 Github Contributors
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
*
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
* libWiiSharp is free software: you can redistribute it and/or
|
||||||
|
* modify it under the terms of the GNU General Public License as published
|
||||||
|
* by the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* libWiiSharp is distributed in the hope that it will be
|
||||||
|
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
@ -10,29 +22,53 @@ using System.Text;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// An IOS patcher which can patch fakesigning, es_identify and nand permissions.
|
||||||
|
/// </summary>
|
||||||
public class IosPatcher
|
public class IosPatcher
|
||||||
{
|
{
|
||||||
private WAD wadFile;
|
private WAD wadFile;
|
||||||
private int esIndex = -1;
|
private int esIndex = -1;
|
||||||
|
|
||||||
public event EventHandler<ProgressChangedEventArgs> Progress;
|
#region Public Functions
|
||||||
|
/// <summary>
|
||||||
public event EventHandler<MessageEventArgs> Debug;
|
/// Loads an IOS wad to patch the es module.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="iosWad"></param>
|
||||||
public void LoadIOS(ref WAD iosWad)
|
public void LoadIOS(ref WAD iosWad)
|
||||||
{
|
{
|
||||||
this.wadFile = iosWad;
|
this.wadFile = iosWad;
|
||||||
this.getEsIndex();
|
this.getEsIndex();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches fakesigning.
|
||||||
|
/// Returns the number of applied patches.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public int PatchFakeSigning() => this.esIndex < 0 ? -1 : this.patchFakeSigning(ref this.wadFile.Contents[this.esIndex]);
|
public int PatchFakeSigning() => this.esIndex < 0 ? -1 : this.patchFakeSigning(ref this.wadFile.Contents[this.esIndex]);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches es_identify.
|
||||||
|
/// Returns the number of applied patches.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public int PatchEsIdentify() => this.esIndex < 0 ? -1 : this.patchEsIdentify(ref this.wadFile.Contents[this.esIndex]);
|
public int PatchEsIdentify() => this.esIndex < 0 ? -1 : this.patchEsIdentify(ref this.wadFile.Contents[this.esIndex]);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches nand permissions.
|
||||||
|
/// Returns the number of applied patches.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public int PatchNandPermissions() => this.esIndex < 0 ? -1 : this.patchNandPermissions(ref this.wadFile.Contents[this.esIndex]);
|
public int PatchNandPermissions() => this.esIndex < 0 ? -1 : this.patchNandPermissions(ref this.wadFile.Contents[this.esIndex]);
|
||||||
|
|
||||||
public int PatchVP() => this.esIndex < 0 ? -1 : this.patchVP(ref this.wadFile.Contents[this.esIndex]);
|
public int PatchVP() => this.esIndex < 0 ? -1 : this.patchVP(ref this.wadFile.Contents[this.esIndex]);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Patches fakesigning, es_identify and nand permissions.
|
||||||
|
/// Returns the number of applied patches.
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
public int PatchAll() => this.esIndex < 0 ? -1 : this.patchAll(ref this.wadFile.Contents[this.esIndex]);
|
public int PatchAll() => this.esIndex < 0 ? -1 : this.patchAll(ref this.wadFile.Contents[this.esIndex]);
|
||||||
|
|
||||||
public int PatchFakeSigning(ref byte[] esModule) => this.patchFakeSigning(ref esModule);
|
public int PatchFakeSigning(ref byte[] esModule) => this.patchFakeSigning(ref esModule);
|
||||||
|
@ -44,7 +80,9 @@ namespace libWiiSharp
|
||||||
public int PatchVP(ref byte[] esModule) => this.patchVP(ref esModule);
|
public int PatchVP(ref byte[] esModule) => this.patchVP(ref esModule);
|
||||||
|
|
||||||
public int PatchAll(ref byte[] esModule) => this.patchAll(ref esModule);
|
public int PatchAll(ref byte[] esModule) => this.patchAll(ref esModule);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Private Functions
|
||||||
private int patchFakeSigning(ref byte[] esModule)
|
private int patchFakeSigning(ref byte[] esModule)
|
||||||
{
|
{
|
||||||
this.fireDebug("Patching Fakesigning...");
|
this.fireDebug("Patching Fakesigning...");
|
||||||
|
@ -266,7 +304,17 @@ namespace libWiiSharp
|
||||||
this.fireDebug("/!\\/!\\/!\\ ES Module wasn't found! /!\\/!\\/!\\");
|
this.fireDebug("/!\\/!\\/!\\ ES Module wasn't found! /!\\/!\\/!\\");
|
||||||
throw new Exception("ES module wasn't found!");
|
throw new Exception("ES module wasn't found!");
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Events
|
||||||
|
/// <summary>
|
||||||
|
/// Fires the Progress of various operations
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<ProgressChangedEventArgs> Progress;
|
||||||
|
/// <summary>
|
||||||
|
/// Fires debugging messages. You may write them into a log file or log textbox.
|
||||||
|
/// </summary>
|
||||||
|
public event EventHandler<MessageEventArgs> Debug;
|
||||||
private void fireDebug(string debugMessage, params object[] args)
|
private void fireDebug(string debugMessage, params object[] args)
|
||||||
{
|
{
|
||||||
EventHandler<MessageEventArgs> debug = this.Debug;
|
EventHandler<MessageEventArgs> debug = this.Debug;
|
||||||
|
@ -282,5 +330,6 @@ namespace libWiiSharp
|
||||||
return;
|
return;
|
||||||
progress(new object(), new ProgressChangedEventArgs(progressPercentage, (object) string.Empty));
|
progress(new object(), new ProgressChangedEventArgs(progressPercentage, (object) string.Empty));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +0,0 @@
|
||||||
// Decompiled with JetBrains decompiler
|
|
||||||
// Type: libWiiSharp.LowerTitleID
|
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
|
||||||
|
|
||||||
namespace libWiiSharp
|
|
||||||
{
|
|
||||||
public enum LowerTitleID : uint
|
|
||||||
{
|
|
||||||
SystemTitles = 1,
|
|
||||||
Channel = 65537, // 0x00010001
|
|
||||||
SystemChannels = 65538, // 0x00010002
|
|
||||||
GameChannel = 65540, // 0x00010004
|
|
||||||
DLC = 65541, // 0x00010005
|
|
||||||
HiddenChannels = 65544, // 0x00010008
|
|
||||||
}
|
|
||||||
}
|
|
15
Protocol.cs
15
Protocol.cs
|
@ -1,15 +0,0 @@
|
||||||
// Decompiled with JetBrains decompiler
|
|
||||||
// Type: libWiiSharp.Protocol
|
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
|
||||||
|
|
||||||
namespace libWiiSharp
|
|
||||||
{
|
|
||||||
public enum Protocol
|
|
||||||
{
|
|
||||||
HAXX,
|
|
||||||
JODI,
|
|
||||||
Custom,
|
|
||||||
}
|
|
||||||
}
|
|
6
TMD.cs
6
TMD.cs
|
@ -11,6 +11,12 @@ using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
public enum ContentType : ushort
|
||||||
|
{
|
||||||
|
Normal = 1,
|
||||||
|
DLC = 16385, // 0x4001
|
||||||
|
Shared = 32769, // 0x8001
|
||||||
|
}
|
||||||
public class TMD : IDisposable
|
public class TMD : IDisposable
|
||||||
{
|
{
|
||||||
private bool fakeSign;
|
private bool fakeSign;
|
||||||
|
|
|
@ -10,6 +10,13 @@ using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public enum CommonKeyType : byte
|
||||||
|
{
|
||||||
|
Standard = 0x00,
|
||||||
|
Korean = 0x01,
|
||||||
|
}
|
||||||
|
|
||||||
public class Ticket : IDisposable
|
public class Ticket : IDisposable
|
||||||
{
|
{
|
||||||
private byte newKeyIndex;
|
private byte newKeyIndex;
|
||||||
|
|
43
WAD.cs
43
WAD.cs
|
@ -13,6 +13,15 @@ using System.Text;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
|
public enum LowerTitleID : uint
|
||||||
|
{
|
||||||
|
SystemTitles = 0x00000001,
|
||||||
|
SystemChannels = 0x00010002,
|
||||||
|
Channel = 0x00010001,
|
||||||
|
GameChannel = 0x00010004,
|
||||||
|
DLC = 0x00010005,
|
||||||
|
HiddenChannels = 0x00010008,
|
||||||
|
}
|
||||||
public class WAD : IDisposable
|
public class WAD : IDisposable
|
||||||
{
|
{
|
||||||
private SHA1 sha = SHA1.Create();
|
private SHA1 sha = SHA1.Create();
|
||||||
|
@ -999,4 +1008,38 @@ namespace libWiiSharp
|
||||||
|
|
||||||
private void bannerApp_Warning(object sender, MessageEventArgs e) => this.fireWarning(e.Message);
|
private void bannerApp_Warning(object sender, MessageEventArgs e) => this.fireWarning(e.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class WAD_Header
|
||||||
|
{
|
||||||
|
private uint headerSize = 0x20;
|
||||||
|
private uint wadType = 0x49730000;
|
||||||
|
private uint certSize = 0xA00;
|
||||||
|
private uint reserved = 0x00;
|
||||||
|
private uint tikSize = 0x2A4;
|
||||||
|
private uint tmdSize;
|
||||||
|
private uint contentSize;
|
||||||
|
private uint footerSize = 0x00;
|
||||||
|
|
||||||
|
public uint HeaderSize { get { return headerSize; } }
|
||||||
|
public uint WadType { get { return wadType; } set { wadType = value; } }
|
||||||
|
public uint CertSize { get { return certSize; } }
|
||||||
|
public uint Reserved { get { return reserved; } }
|
||||||
|
public uint TicketSize { get { return tikSize; } }
|
||||||
|
public uint TmdSize { get { return tmdSize; } set { tmdSize = value; } }
|
||||||
|
public uint ContentSize { get { return contentSize; } set { contentSize = value; } }
|
||||||
|
public uint FooterSize { get { return footerSize; } set { footerSize = value; } }
|
||||||
|
|
||||||
|
public void Write(Stream writeStream)
|
||||||
|
{
|
||||||
|
writeStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(headerSize)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(wadType)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(certSize)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(reserved)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(tikSize)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(tmdSize)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(contentSize)), 0, 4);
|
||||||
|
writeStream.Write(BitConverter.GetBytes(Shared.Swap(footerSize)), 0, 4);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,68 +0,0 @@
|
||||||
// Decompiled with JetBrains decompiler
|
|
||||||
// Type: libWiiSharp.WAD_Header
|
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace libWiiSharp
|
|
||||||
{
|
|
||||||
public class WAD_Header
|
|
||||||
{
|
|
||||||
private uint headerSize = 32;
|
|
||||||
private uint wadType = 1232273408;
|
|
||||||
private uint certSize = 2560;
|
|
||||||
private uint reserved;
|
|
||||||
private uint tikSize = 676;
|
|
||||||
private uint tmdSize;
|
|
||||||
private uint contentSize;
|
|
||||||
private uint footerSize;
|
|
||||||
|
|
||||||
public uint HeaderSize => this.headerSize;
|
|
||||||
|
|
||||||
public uint WadType
|
|
||||||
{
|
|
||||||
get => this.wadType;
|
|
||||||
set => this.wadType = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint CertSize => this.certSize;
|
|
||||||
|
|
||||||
public uint Reserved => this.reserved;
|
|
||||||
|
|
||||||
public uint TicketSize => this.tikSize;
|
|
||||||
|
|
||||||
public uint TmdSize
|
|
||||||
{
|
|
||||||
get => this.tmdSize;
|
|
||||||
set => this.tmdSize = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint ContentSize
|
|
||||||
{
|
|
||||||
get => this.contentSize;
|
|
||||||
set => this.contentSize = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint FooterSize
|
|
||||||
{
|
|
||||||
get => this.footerSize;
|
|
||||||
set => this.footerSize = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Stream writeStream)
|
|
||||||
{
|
|
||||||
writeStream.Seek(0L, SeekOrigin.Begin);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.headerSize)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.wadType)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.certSize)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.reserved)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.tikSize)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.tmdSize)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.contentSize)), 0, 4);
|
|
||||||
writeStream.Write(BitConverter.GetBytes(Shared.Swap(this.footerSize)), 0, 4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -55,18 +55,14 @@
|
||||||
<Compile Include="CertificateChain.cs" />
|
<Compile Include="CertificateChain.cs" />
|
||||||
<Compile Include="ColorIndexConverter.cs" />
|
<Compile Include="ColorIndexConverter.cs" />
|
||||||
<Compile Include="CommonKey.cs" />
|
<Compile Include="CommonKey.cs" />
|
||||||
<Compile Include="CommonKeyType.cs" />
|
|
||||||
<Compile Include="ContentIndices.cs" />
|
<Compile Include="ContentIndices.cs" />
|
||||||
<Compile Include="ContentType.cs" />
|
|
||||||
<Compile Include="HbcTransmitter.cs" />
|
<Compile Include="HbcTransmitter.cs" />
|
||||||
<Compile Include="Headers.cs" />
|
<Compile Include="Headers.cs" />
|
||||||
<Compile Include="HexView.cs" />
|
<Compile Include="HexView.cs" />
|
||||||
<Compile Include="IosPatcher.cs" />
|
<Compile Include="IosPatcher.cs" />
|
||||||
<Compile Include="LowerTitleID.cs" />
|
|
||||||
<Compile Include="Lz77.cs" />
|
<Compile Include="Lz77.cs" />
|
||||||
<Compile Include="MessageEventArgs.cs" />
|
<Compile Include="MessageEventArgs.cs" />
|
||||||
<Compile Include="NusClient.cs" />
|
<Compile Include="NusClient.cs" />
|
||||||
<Compile Include="Protocol.cs" />
|
|
||||||
<Compile Include="Region.cs" />
|
<Compile Include="Region.cs" />
|
||||||
<Compile Include="Shared.cs" />
|
<Compile Include="Shared.cs" />
|
||||||
<Compile Include="StoreType.cs" />
|
<Compile Include="StoreType.cs" />
|
||||||
|
@ -85,14 +81,12 @@
|
||||||
<Compile Include="U8_Node.cs" />
|
<Compile Include="U8_Node.cs" />
|
||||||
<Compile Include="U8_NodeType.cs" />
|
<Compile Include="U8_NodeType.cs" />
|
||||||
<Compile Include="WAD.cs" />
|
<Compile Include="WAD.cs" />
|
||||||
<Compile Include="WAD_Header.cs" />
|
|
||||||
<Compile Include="Wave.cs" />
|
<Compile Include="Wave.cs" />
|
||||||
<Compile Include="WaveDataChunk.cs" />
|
<Compile Include="WaveDataChunk.cs" />
|
||||||
<Compile Include="WaveFmtChunk.cs" />
|
<Compile Include="WaveFmtChunk.cs" />
|
||||||
<Compile Include="WaveHeader.cs" />
|
<Compile Include="WaveHeader.cs" />
|
||||||
<Compile Include="WaveSmplChunk.cs" />
|
<Compile Include="WaveSmplChunk.cs" />
|
||||||
<Compile Include="WaveSmplLoop.cs" />
|
<Compile Include="WaveSmplLoop.cs" />
|
||||||
<Compile Include="zlibWrapper.cs" />
|
|
||||||
<Compile Include="AssemblyInfo.cs" />
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
6
libWiiSharp.csproj.user
Normal file
6
libWiiSharp.csproj.user
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
|
@ -1,46 +0,0 @@
|
||||||
// Decompiled with JetBrains decompiler
|
|
||||||
// Type: libWiiSharp.zlibWrapper
|
|
||||||
// Assembly: libWiiSharp, Version=0.4.0.0, Culture=neutral, PublicKeyToken=null
|
|
||||||
// MVID: FBF36F3D-B5D6-481F-B5F5-1BD3C19E13B2
|
|
||||||
// Assembly location: C:\Users\theso\Downloads\NCPatcher\pack\libWiiSharp.dll
|
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
|
|
||||||
namespace libWiiSharp
|
|
||||||
{
|
|
||||||
internal class zlibWrapper
|
|
||||||
{
|
|
||||||
[DllImport("zlib1.dll")]
|
|
||||||
private static extern zlibWrapper.ZLibError compress2(
|
|
||||||
byte[] dest,
|
|
||||||
ref int destLength,
|
|
||||||
byte[] source,
|
|
||||||
int sourceLength,
|
|
||||||
int level);
|
|
||||||
|
|
||||||
public static byte[] Compress(byte[] inFile)
|
|
||||||
{
|
|
||||||
byte[] array = new byte[inFile.Length + 64];
|
|
||||||
int destLength = -1;
|
|
||||||
zlibWrapper.ZLibError zlibError = zlibWrapper.compress2(array, ref destLength, inFile, inFile.Length, 6);
|
|
||||||
if (zlibError != zlibWrapper.ZLibError.Z_OK || destLength <= -1 || destLength >= inFile.Length)
|
|
||||||
throw new Exception("An error occured while compressing! Code: " + zlibError.ToString());
|
|
||||||
Array.Resize<byte>(ref array, destLength);
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ZLibError
|
|
||||||
{
|
|
||||||
Z_VERSION_ERROR = -6, // 0xFFFFFFFA
|
|
||||||
Z_BUF_ERROR = -5, // 0xFFFFFFFB
|
|
||||||
Z_MEM_ERROR = -4, // 0xFFFFFFFC
|
|
||||||
Z_DATA_ERROR = -3, // 0xFFFFFFFD
|
|
||||||
Z_STREAM_ERROR = -2, // 0xFFFFFFFE
|
|
||||||
Z_ERRNO = -1, // 0xFFFFFFFF
|
|
||||||
Z_OK = 0,
|
|
||||||
Z_STREAM_END = 1,
|
|
||||||
Z_NEED_DICT = 2,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in a new issue