mirror of
https://github.com/TheShadowEevee/libWiiSharp.git
synced 2025-01-11 15:38:51 -06:00
Begin Formatting/Recommenting
This commit is contained in:
parent
b9c57a8ae9
commit
6e865ca4af
11 changed files with 1857 additions and 1681 deletions
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
/.vs
|
||||||
|
/bin
|
||||||
|
/obj
|
|
@ -3,14 +3,14 @@ using System.Resources;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Security.Permissions;
|
using System.Security.Permissions;
|
||||||
|
|
||||||
[assembly: AssemblyTitle("libWiiSharp_ModMii")]
|
[assembly: AssemblyTitle("libWiiSharp_Modified")]
|
||||||
[assembly: AssemblyDescription("a wii related .NET library modified for ModMii")]
|
[assembly: AssemblyDescription("a wii related .NET library modified to add features for othe programs.")]
|
||||||
[assembly: AssemblyConfiguration("")]
|
[assembly: AssemblyConfiguration("")]
|
||||||
[assembly: AssemblyCompany("Leathl,SC reproductions")]
|
[assembly: AssemblyCompany("Leathl,SC reproductions")]
|
||||||
[assembly: AssemblyProduct("libWiiSharp_ModMii")]
|
[assembly: AssemblyProduct("libWiiSharp_Modified")]
|
||||||
[assembly: AssemblyCopyright("Copyright © Leathl 2011")]
|
[assembly: AssemblyCopyright("Copyright © Leathl 2011, Copyright © Github Contributors 2020")]
|
||||||
[assembly: AssemblyTrademark("")]
|
[assembly: AssemblyTrademark("")]
|
||||||
[assembly: ComVisible(false)]
|
[assembly: ComVisible(true)]
|
||||||
[assembly: Guid("af701263-5875-4866-9c09-d7f62e9f0ff0")]
|
[assembly: Guid("af701263-5875-4866-9c09-d7f62e9f0ff0")]
|
||||||
[assembly: AssemblyFileVersion("0.4.0.0")]
|
[assembly: AssemblyFileVersion("0.4.0.0")]
|
||||||
[assembly: NeutralResourcesLanguage("en")]
|
[assembly: NeutralResourcesLanguage("en")]
|
||||||
|
|
88
BNS_Data.cs
88
BNS_Data.cs
|
@ -1,51 +1,63 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.BNS_Data
|
* 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;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
internal class BNS_Data
|
internal class BNS_Data
|
||||||
{
|
|
||||||
private byte[] magic = new byte[4]
|
|
||||||
{
|
{
|
||||||
(byte) 68,
|
private byte[] magic = new byte[4]
|
||||||
(byte) 65,
|
{
|
||||||
(byte) 84,
|
(byte) 68,
|
||||||
(byte) 65
|
(byte) 65,
|
||||||
};
|
(byte) 84,
|
||||||
private uint size = 315392;
|
(byte) 65
|
||||||
private byte[] data;
|
};
|
||||||
|
private uint size = 315392;
|
||||||
|
private byte[] data;
|
||||||
|
|
||||||
public uint Size
|
public uint Size
|
||||||
{
|
{
|
||||||
get => this.size;
|
get => this.size;
|
||||||
set => this.size = value;
|
set => this.size = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] Data
|
public byte[] Data
|
||||||
{
|
{
|
||||||
get => this.data;
|
get => this.data;
|
||||||
set => this.data = value;
|
set => this.data = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(Stream outStream)
|
public void Write(Stream outStream)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes(Shared.Swap(this.size));
|
byte[] bytes = BitConverter.GetBytes(Shared.Swap(this.size));
|
||||||
outStream.Write(this.magic, 0, this.magic.Length);
|
outStream.Write(this.magic, 0, this.magic.Length);
|
||||||
outStream.Write(bytes, 0, bytes.Length);
|
outStream.Write(bytes, 0, bytes.Length);
|
||||||
outStream.Write(this.data, 0, this.data.Length);
|
outStream.Write(this.data, 0, this.data.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Read(Stream input)
|
public void Read(Stream input)
|
||||||
{
|
{
|
||||||
BinaryReader binaryReader = new BinaryReader(input);
|
BinaryReader binaryReader = new BinaryReader(input);
|
||||||
this.size = Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)) ? Shared.Swap(binaryReader.ReadUInt32()) : throw new Exception("This is not a valid BNS audfo file!");
|
this.size = Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)) ? Shared.Swap(binaryReader.ReadUInt32()) : throw new Exception("This is not a valid BNS audfo file!");
|
||||||
this.data = binaryReader.ReadBytes((int) this.size - 8);
|
this.data = binaryReader.ReadBytes((int) this.size - 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
196
BNS_Header.cs
196
BNS_Header.cs
|
@ -1,108 +1,120 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.BNS_Header
|
* 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;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
internal class BNS_Header
|
internal class BNS_Header
|
||||||
{
|
|
||||||
private byte[] magic = new byte[4]
|
|
||||||
{
|
{
|
||||||
(byte) 66,
|
private byte[] magic = new byte[4]
|
||||||
(byte) 78,
|
{
|
||||||
(byte) 83,
|
(byte) 66,
|
||||||
(byte) 32
|
(byte) 78,
|
||||||
};
|
(byte) 83,
|
||||||
private uint flags = 4278124800;
|
(byte) 32
|
||||||
private uint fileSize = 315584;
|
};
|
||||||
private ushort size = 32;
|
private uint flags = 4278124800;
|
||||||
private ushort chunkCount = 2;
|
private uint fileSize = 315584;
|
||||||
private uint infoOffset = 32;
|
private ushort size = 32;
|
||||||
private uint infoLength = 160;
|
private ushort chunkCount = 2;
|
||||||
private uint dataOffset = 192;
|
private uint infoOffset = 32;
|
||||||
private uint dataLength = 315392;
|
private uint infoLength = 160;
|
||||||
|
private uint dataOffset = 192;
|
||||||
|
private uint dataLength = 315392;
|
||||||
|
|
||||||
public uint DataOffset
|
public uint DataOffset
|
||||||
{
|
{
|
||||||
get => this.dataOffset;
|
get => this.dataOffset;
|
||||||
set => this.dataOffset = value;
|
set => this.dataOffset = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint InfoLength
|
public uint InfoLength
|
||||||
{
|
{
|
||||||
get => this.infoLength;
|
get => this.infoLength;
|
||||||
set => this.infoLength = value;
|
set => this.infoLength = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ushort Size
|
public ushort Size
|
||||||
{
|
{
|
||||||
get => this.size;
|
get => this.size;
|
||||||
set => this.size = value;
|
set => this.size = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint DataLength
|
public uint DataLength
|
||||||
{
|
{
|
||||||
get => this.dataLength;
|
get => this.dataLength;
|
||||||
set => this.dataLength = value;
|
set => this.dataLength = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public uint FileSize
|
public uint FileSize
|
||||||
{
|
{
|
||||||
get => this.fileSize;
|
get => this.fileSize;
|
||||||
set => this.fileSize = value;
|
set => this.fileSize = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write(Stream outStream)
|
public void Write(Stream outStream)
|
||||||
{
|
{
|
||||||
outStream.Write(this.magic, 0, this.magic.Length);
|
outStream.Write(this.magic, 0, this.magic.Length);
|
||||||
byte[] bytes1 = BitConverter.GetBytes(this.flags);
|
byte[] bytes1 = BitConverter.GetBytes(this.flags);
|
||||||
Array.Reverse((Array) bytes1);
|
Array.Reverse((Array) bytes1);
|
||||||
outStream.Write(bytes1, 0, bytes1.Length);
|
outStream.Write(bytes1, 0, bytes1.Length);
|
||||||
byte[] bytes2 = BitConverter.GetBytes(this.fileSize);
|
byte[] bytes2 = BitConverter.GetBytes(this.fileSize);
|
||||||
Array.Reverse((Array) bytes2);
|
Array.Reverse((Array) bytes2);
|
||||||
outStream.Write(bytes2, 0, bytes2.Length);
|
outStream.Write(bytes2, 0, bytes2.Length);
|
||||||
byte[] bytes3 = BitConverter.GetBytes(this.size);
|
byte[] bytes3 = BitConverter.GetBytes(this.size);
|
||||||
Array.Reverse((Array) bytes3);
|
Array.Reverse((Array) bytes3);
|
||||||
outStream.Write(bytes3, 0, bytes3.Length);
|
outStream.Write(bytes3, 0, bytes3.Length);
|
||||||
byte[] bytes4 = BitConverter.GetBytes(this.chunkCount);
|
byte[] bytes4 = BitConverter.GetBytes(this.chunkCount);
|
||||||
Array.Reverse((Array) bytes4);
|
Array.Reverse((Array) bytes4);
|
||||||
outStream.Write(bytes4, 0, bytes4.Length);
|
outStream.Write(bytes4, 0, bytes4.Length);
|
||||||
byte[] bytes5 = BitConverter.GetBytes(this.infoOffset);
|
byte[] bytes5 = BitConverter.GetBytes(this.infoOffset);
|
||||||
Array.Reverse((Array) bytes5);
|
Array.Reverse((Array) bytes5);
|
||||||
outStream.Write(bytes5, 0, bytes5.Length);
|
outStream.Write(bytes5, 0, bytes5.Length);
|
||||||
byte[] bytes6 = BitConverter.GetBytes(this.infoLength);
|
byte[] bytes6 = BitConverter.GetBytes(this.infoLength);
|
||||||
Array.Reverse((Array) bytes6);
|
Array.Reverse((Array) bytes6);
|
||||||
outStream.Write(bytes6, 0, bytes6.Length);
|
outStream.Write(bytes6, 0, bytes6.Length);
|
||||||
byte[] bytes7 = BitConverter.GetBytes(this.dataOffset);
|
byte[] bytes7 = BitConverter.GetBytes(this.dataOffset);
|
||||||
Array.Reverse((Array) bytes7);
|
Array.Reverse((Array) bytes7);
|
||||||
outStream.Write(bytes7, 0, bytes7.Length);
|
outStream.Write(bytes7, 0, bytes7.Length);
|
||||||
byte[] bytes8 = BitConverter.GetBytes(this.dataLength);
|
byte[] bytes8 = BitConverter.GetBytes(this.dataLength);
|
||||||
Array.Reverse((Array) bytes8);
|
Array.Reverse((Array) bytes8);
|
||||||
outStream.Write(bytes8, 0, bytes8.Length);
|
outStream.Write(bytes8, 0, bytes8.Length);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Read(Stream input)
|
public void Read(Stream input)
|
||||||
{
|
{
|
||||||
BinaryReader binaryReader = new BinaryReader(input);
|
BinaryReader binaryReader = new BinaryReader(input);
|
||||||
if (!Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)))
|
if (!Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)))
|
||||||
{
|
{
|
||||||
binaryReader.BaseStream.Seek(28L, SeekOrigin.Current);
|
binaryReader.BaseStream.Seek(28L, SeekOrigin.Current);
|
||||||
if (!Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)))
|
if (!Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)))
|
||||||
throw new Exception("This is not a valid BNS audfo file!");
|
throw new Exception("This is not a valid BNS audio file!");
|
||||||
}
|
}
|
||||||
this.flags = Shared.Swap(binaryReader.ReadUInt32());
|
this.flags = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
this.fileSize = Shared.Swap(binaryReader.ReadUInt32());
|
this.fileSize = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
this.size = Shared.Swap(binaryReader.ReadUInt16());
|
this.size = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
this.chunkCount = Shared.Swap(binaryReader.ReadUInt16());
|
this.chunkCount = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
this.infoOffset = Shared.Swap(binaryReader.ReadUInt32());
|
this.infoOffset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
this.infoLength = Shared.Swap(binaryReader.ReadUInt32());
|
this.infoLength = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
this.dataOffset = Shared.Swap(binaryReader.ReadUInt32());
|
this.dataOffset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
this.dataLength = Shared.Swap(binaryReader.ReadUInt32());
|
this.dataLength = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
694
BNS_Info.cs
694
BNS_Info.cs
|
@ -1,351 +1,365 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.BNS_Info
|
* 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;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
internal class BNS_Info
|
internal class BNS_Info
|
||||||
{
|
|
||||||
private byte[] magic = new byte[4]
|
|
||||||
{
|
{
|
||||||
(byte) 73,
|
//Private Variables
|
||||||
(byte) 78,
|
private byte[] magic = new byte[4]
|
||||||
(byte) 70,
|
|
||||||
(byte) 79
|
|
||||||
};
|
|
||||||
private uint size = 160;
|
|
||||||
private byte codec;
|
|
||||||
private byte hasLoop;
|
|
||||||
private byte channelCount = 2;
|
|
||||||
private byte zero;
|
|
||||||
private ushort sampleRate = 44100;
|
|
||||||
private ushort pad0;
|
|
||||||
private uint loopStart;
|
|
||||||
private uint loopEnd;
|
|
||||||
private uint offsetToChannelStart = 24;
|
|
||||||
private uint pad1;
|
|
||||||
private uint channel1StartOffset = 32;
|
|
||||||
private uint channel2StartOffset = 44;
|
|
||||||
private uint channel1Start;
|
|
||||||
private uint coefficients1Offset = 56;
|
|
||||||
private uint pad2;
|
|
||||||
private uint channel2Start;
|
|
||||||
private uint coefficients2Offset = 104;
|
|
||||||
private uint pad3;
|
|
||||||
private int[] coefficients1 = new int[16];
|
|
||||||
private ushort channel1Gain;
|
|
||||||
private ushort channel1PredictiveScale;
|
|
||||||
private ushort channel1PreviousValue;
|
|
||||||
private ushort channel1NextPreviousValue;
|
|
||||||
private ushort channel1LoopPredictiveScale;
|
|
||||||
private ushort channel1LoopPreviousValue;
|
|
||||||
private ushort channel1LoopNextPreviousValue;
|
|
||||||
private ushort channel1LoopPadding;
|
|
||||||
private int[] coefficients2 = new int[16];
|
|
||||||
private ushort channel2Gain;
|
|
||||||
private ushort channel2PredictiveScale;
|
|
||||||
private ushort channel2PreviousValue;
|
|
||||||
private ushort channel2NextPreviousValue;
|
|
||||||
private ushort channel2LoopPredictiveScale;
|
|
||||||
private ushort channel2LoopPreviousValue;
|
|
||||||
private ushort channel2LoopNextPreviousValue;
|
|
||||||
private ushort channel2LoopPadding;
|
|
||||||
|
|
||||||
public byte HasLoop
|
|
||||||
{
|
|
||||||
get => this.hasLoop;
|
|
||||||
set => this.hasLoop = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Coefficients1Offset
|
|
||||||
{
|
|
||||||
get => this.coefficients1Offset;
|
|
||||||
set => this.coefficients1Offset = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Channel1StartOffset
|
|
||||||
{
|
|
||||||
get => this.channel1StartOffset;
|
|
||||||
set => this.channel1StartOffset = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Channel2StartOffset
|
|
||||||
{
|
|
||||||
get => this.channel2StartOffset;
|
|
||||||
set => this.channel2StartOffset = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Size
|
|
||||||
{
|
|
||||||
get => this.size;
|
|
||||||
set => this.size = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ushort SampleRate
|
|
||||||
{
|
|
||||||
get => this.sampleRate;
|
|
||||||
set => this.sampleRate = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte ChannelCount
|
|
||||||
{
|
|
||||||
get => this.channelCount;
|
|
||||||
set => this.channelCount = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Channel1Start
|
|
||||||
{
|
|
||||||
get => this.channel1Start;
|
|
||||||
set => this.channel1Start = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint Channel2Start
|
|
||||||
{
|
|
||||||
get => this.channel2Start;
|
|
||||||
set => this.channel2Start = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint LoopStart
|
|
||||||
{
|
|
||||||
get => this.loopStart;
|
|
||||||
set => this.loopStart = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public uint LoopEnd
|
|
||||||
{
|
|
||||||
get => this.loopEnd;
|
|
||||||
set => this.loopEnd = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] Coefficients1
|
|
||||||
{
|
|
||||||
get => this.coefficients1;
|
|
||||||
set => this.coefficients1 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int[] Coefficients2
|
|
||||||
{
|
|
||||||
get => this.coefficients2;
|
|
||||||
set => this.coefficients2 = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Write(Stream outStream)
|
|
||||||
{
|
|
||||||
outStream.Write(this.magic, 0, this.magic.Length);
|
|
||||||
byte[] bytes1 = BitConverter.GetBytes(this.size);
|
|
||||||
Array.Reverse((Array) bytes1);
|
|
||||||
outStream.Write(bytes1, 0, bytes1.Length);
|
|
||||||
outStream.WriteByte(this.codec);
|
|
||||||
outStream.WriteByte(this.hasLoop);
|
|
||||||
outStream.WriteByte(this.channelCount);
|
|
||||||
outStream.WriteByte(this.zero);
|
|
||||||
byte[] bytes2 = BitConverter.GetBytes(this.sampleRate);
|
|
||||||
Array.Reverse((Array) bytes2);
|
|
||||||
outStream.Write(bytes2, 0, bytes2.Length);
|
|
||||||
byte[] bytes3 = BitConverter.GetBytes(this.pad0);
|
|
||||||
Array.Reverse((Array) bytes3);
|
|
||||||
outStream.Write(bytes3, 0, bytes3.Length);
|
|
||||||
byte[] bytes4 = BitConverter.GetBytes(this.loopStart);
|
|
||||||
Array.Reverse((Array) bytes4);
|
|
||||||
outStream.Write(bytes4, 0, bytes4.Length);
|
|
||||||
byte[] bytes5 = BitConverter.GetBytes(this.loopEnd);
|
|
||||||
Array.Reverse((Array) bytes5);
|
|
||||||
outStream.Write(bytes5, 0, bytes5.Length);
|
|
||||||
byte[] bytes6 = BitConverter.GetBytes(this.offsetToChannelStart);
|
|
||||||
Array.Reverse((Array) bytes6);
|
|
||||||
outStream.Write(bytes6, 0, bytes6.Length);
|
|
||||||
byte[] bytes7 = BitConverter.GetBytes(this.pad1);
|
|
||||||
Array.Reverse((Array) bytes7);
|
|
||||||
outStream.Write(bytes7, 0, bytes7.Length);
|
|
||||||
byte[] bytes8 = BitConverter.GetBytes(this.channel1StartOffset);
|
|
||||||
Array.Reverse((Array) bytes8);
|
|
||||||
outStream.Write(bytes8, 0, bytes8.Length);
|
|
||||||
byte[] bytes9 = BitConverter.GetBytes(this.channel2StartOffset);
|
|
||||||
Array.Reverse((Array) bytes9);
|
|
||||||
outStream.Write(bytes9, 0, bytes9.Length);
|
|
||||||
byte[] bytes10 = BitConverter.GetBytes(this.channel1Start);
|
|
||||||
Array.Reverse((Array) bytes10);
|
|
||||||
outStream.Write(bytes10, 0, bytes10.Length);
|
|
||||||
byte[] bytes11 = BitConverter.GetBytes(this.coefficients1Offset);
|
|
||||||
Array.Reverse((Array) bytes11);
|
|
||||||
outStream.Write(bytes11, 0, bytes11.Length);
|
|
||||||
if (this.channelCount == (byte) 2)
|
|
||||||
{
|
|
||||||
byte[] bytes12 = BitConverter.GetBytes(this.pad2);
|
|
||||||
Array.Reverse((Array) bytes12);
|
|
||||||
outStream.Write(bytes12, 0, bytes12.Length);
|
|
||||||
byte[] bytes13 = BitConverter.GetBytes(this.channel2Start);
|
|
||||||
Array.Reverse((Array) bytes13);
|
|
||||||
outStream.Write(bytes13, 0, bytes13.Length);
|
|
||||||
byte[] bytes14 = BitConverter.GetBytes(this.coefficients2Offset);
|
|
||||||
Array.Reverse((Array) bytes14);
|
|
||||||
outStream.Write(bytes14, 0, bytes14.Length);
|
|
||||||
byte[] bytes15 = BitConverter.GetBytes(this.pad3);
|
|
||||||
Array.Reverse((Array) bytes15);
|
|
||||||
outStream.Write(bytes15, 0, bytes15.Length);
|
|
||||||
foreach (int num in this.coefficients1)
|
|
||||||
{
|
{
|
||||||
byte[] bytes16 = BitConverter.GetBytes(num);
|
(byte) 73,
|
||||||
Array.Reverse((Array) bytes16);
|
(byte) 78,
|
||||||
outStream.Write(bytes16, 2, bytes16.Length - 2);
|
(byte) 70,
|
||||||
}
|
(byte) 79
|
||||||
byte[] bytes17 = BitConverter.GetBytes(this.channel1Gain);
|
};
|
||||||
Array.Reverse((Array) bytes17);
|
private uint size = 160;
|
||||||
outStream.Write(bytes17, 0, bytes17.Length);
|
private byte codec;
|
||||||
byte[] bytes18 = BitConverter.GetBytes(this.channel1PredictiveScale);
|
private byte hasLoop;
|
||||||
Array.Reverse((Array) bytes18);
|
private byte channelCount = 2;
|
||||||
outStream.Write(bytes18, 0, bytes18.Length);
|
private byte zero;
|
||||||
byte[] bytes19 = BitConverter.GetBytes(this.channel1PreviousValue);
|
private ushort sampleRate = 44100;
|
||||||
Array.Reverse((Array) bytes19);
|
private ushort pad0;
|
||||||
outStream.Write(bytes19, 0, bytes19.Length);
|
private uint loopStart;
|
||||||
byte[] bytes20 = BitConverter.GetBytes(this.channel1NextPreviousValue);
|
private uint loopEnd; //Or total sample count
|
||||||
Array.Reverse((Array) bytes20);
|
private uint offsetToChannelStart = 24;
|
||||||
outStream.Write(bytes20, 0, bytes20.Length);
|
private uint pad1;
|
||||||
byte[] bytes21 = BitConverter.GetBytes(this.channel1LoopPredictiveScale);
|
private uint channel1StartOffset = 32;
|
||||||
Array.Reverse((Array) bytes21);
|
private uint channel2StartOffset = 44;
|
||||||
outStream.Write(bytes21, 0, bytes21.Length);
|
private uint channel1Start;
|
||||||
byte[] bytes22 = BitConverter.GetBytes(this.channel1LoopPreviousValue);
|
private uint coefficients1Offset = 56;
|
||||||
Array.Reverse((Array) bytes22);
|
private uint pad2;
|
||||||
outStream.Write(bytes22, 0, bytes22.Length);
|
private uint channel2Start;
|
||||||
byte[] bytes23 = BitConverter.GetBytes(this.channel1LoopNextPreviousValue);
|
private uint coefficients2Offset = 104;
|
||||||
Array.Reverse((Array) bytes23);
|
private uint pad3;
|
||||||
outStream.Write(bytes23, 0, bytes23.Length);
|
private int[] coefficients1 = new int[16];
|
||||||
byte[] bytes24 = BitConverter.GetBytes(this.channel1LoopPadding);
|
private ushort channel1Gain;
|
||||||
Array.Reverse((Array) bytes24);
|
private ushort channel1PredictiveScale;
|
||||||
outStream.Write(bytes24, 0, bytes24.Length);
|
private ushort channel1PreviousValue;
|
||||||
foreach (int num in this.coefficients2)
|
private ushort channel1NextPreviousValue;
|
||||||
{
|
private ushort channel1LoopPredictiveScale;
|
||||||
byte[] bytes16 = BitConverter.GetBytes(num);
|
private ushort channel1LoopPreviousValue;
|
||||||
Array.Reverse((Array) bytes16);
|
private ushort channel1LoopNextPreviousValue;
|
||||||
outStream.Write(bytes16, 2, bytes16.Length - 2);
|
private ushort channel1LoopPadding;
|
||||||
}
|
private int[] coefficients2 = new int[16];
|
||||||
byte[] bytes25 = BitConverter.GetBytes(this.channel2Gain);
|
private ushort channel2Gain;
|
||||||
Array.Reverse((Array) bytes25);
|
private ushort channel2PredictiveScale;
|
||||||
outStream.Write(bytes25, 0, bytes25.Length);
|
private ushort channel2PreviousValue;
|
||||||
byte[] bytes26 = BitConverter.GetBytes(this.channel2PredictiveScale);
|
private ushort channel2NextPreviousValue;
|
||||||
Array.Reverse((Array) bytes26);
|
private ushort channel2LoopPredictiveScale;
|
||||||
outStream.Write(bytes26, 0, bytes26.Length);
|
private ushort channel2LoopPreviousValue;
|
||||||
byte[] bytes27 = BitConverter.GetBytes(this.channel2PreviousValue);
|
private ushort channel2LoopNextPreviousValue;
|
||||||
Array.Reverse((Array) bytes27);
|
private ushort channel2LoopPadding;
|
||||||
outStream.Write(bytes27, 0, bytes27.Length);
|
|
||||||
byte[] bytes28 = BitConverter.GetBytes(this.channel2NextPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes28);
|
|
||||||
outStream.Write(bytes28, 0, bytes28.Length);
|
|
||||||
byte[] bytes29 = BitConverter.GetBytes(this.channel2LoopPredictiveScale);
|
|
||||||
Array.Reverse((Array) bytes29);
|
|
||||||
outStream.Write(bytes29, 0, bytes29.Length);
|
|
||||||
byte[] bytes30 = BitConverter.GetBytes(this.channel2LoopPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes30);
|
|
||||||
outStream.Write(bytes30, 0, bytes30.Length);
|
|
||||||
byte[] bytes31 = BitConverter.GetBytes(this.channel2LoopNextPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes31);
|
|
||||||
outStream.Write(bytes31, 0, bytes31.Length);
|
|
||||||
byte[] bytes32 = BitConverter.GetBytes(this.channel2LoopPadding);
|
|
||||||
Array.Reverse((Array) bytes32);
|
|
||||||
outStream.Write(bytes32, 0, bytes32.Length);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (this.channelCount != (byte) 1)
|
|
||||||
return;
|
|
||||||
foreach (int num in this.coefficients1)
|
|
||||||
{
|
|
||||||
byte[] bytes12 = BitConverter.GetBytes(num);
|
|
||||||
Array.Reverse((Array) bytes12);
|
|
||||||
outStream.Write(bytes12, 2, bytes12.Length - 2);
|
|
||||||
}
|
|
||||||
byte[] bytes13 = BitConverter.GetBytes(this.channel1Gain);
|
|
||||||
Array.Reverse((Array) bytes13);
|
|
||||||
outStream.Write(bytes13, 0, bytes13.Length);
|
|
||||||
byte[] bytes14 = BitConverter.GetBytes(this.channel1PredictiveScale);
|
|
||||||
Array.Reverse((Array) bytes14);
|
|
||||||
outStream.Write(bytes14, 0, bytes14.Length);
|
|
||||||
byte[] bytes15 = BitConverter.GetBytes(this.channel1PreviousValue);
|
|
||||||
Array.Reverse((Array) bytes15);
|
|
||||||
outStream.Write(bytes15, 0, bytes15.Length);
|
|
||||||
byte[] bytes16 = BitConverter.GetBytes(this.channel1NextPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes16);
|
|
||||||
outStream.Write(bytes16, 0, bytes16.Length);
|
|
||||||
byte[] bytes17 = BitConverter.GetBytes(this.channel1LoopPredictiveScale);
|
|
||||||
Array.Reverse((Array) bytes17);
|
|
||||||
outStream.Write(bytes17, 0, bytes17.Length);
|
|
||||||
byte[] bytes18 = BitConverter.GetBytes(this.channel1LoopPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes18);
|
|
||||||
outStream.Write(bytes18, 0, bytes18.Length);
|
|
||||||
byte[] bytes19 = BitConverter.GetBytes(this.channel1LoopNextPreviousValue);
|
|
||||||
Array.Reverse((Array) bytes19);
|
|
||||||
outStream.Write(bytes19, 0, bytes19.Length);
|
|
||||||
byte[] bytes20 = BitConverter.GetBytes(this.channel1LoopPadding);
|
|
||||||
Array.Reverse((Array) bytes20);
|
|
||||||
outStream.Write(bytes20, 0, bytes20.Length);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Read(Stream input)
|
//Public Variables
|
||||||
{
|
public byte HasLoop
|
||||||
BinaryReader binaryReader = new BinaryReader(input);
|
{
|
||||||
this.size = Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)) ? Shared.Swap(binaryReader.ReadUInt32()) : throw new Exception("This is not a valid BNS audfo file!");
|
get => this.hasLoop;
|
||||||
this.codec = binaryReader.ReadByte();
|
set => this.hasLoop = value;
|
||||||
this.hasLoop = binaryReader.ReadByte();
|
}
|
||||||
this.channelCount = binaryReader.ReadByte();
|
|
||||||
this.zero = binaryReader.ReadByte();
|
public uint Coefficients1Offset
|
||||||
this.sampleRate = Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.pad0 = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.coefficients1Offset;
|
||||||
this.loopStart = Shared.Swap(binaryReader.ReadUInt32());
|
set => this.coefficients1Offset = value;
|
||||||
this.loopEnd = Shared.Swap(binaryReader.ReadUInt32());
|
}
|
||||||
this.offsetToChannelStart = Shared.Swap(binaryReader.ReadUInt32());
|
|
||||||
this.pad1 = Shared.Swap(binaryReader.ReadUInt32());
|
public uint Channel1StartOffset
|
||||||
this.channel1StartOffset = Shared.Swap(binaryReader.ReadUInt32());
|
{
|
||||||
this.channel2StartOffset = Shared.Swap(binaryReader.ReadUInt32());
|
get => this.channel1StartOffset;
|
||||||
this.channel1Start = Shared.Swap(binaryReader.ReadUInt32());
|
set => this.channel1StartOffset = value;
|
||||||
this.coefficients1Offset = Shared.Swap(binaryReader.ReadUInt32());
|
}
|
||||||
if (this.channelCount == (byte) 2)
|
|
||||||
{
|
public uint Channel2StartOffset
|
||||||
this.pad2 = Shared.Swap(binaryReader.ReadUInt32());
|
{
|
||||||
this.channel2Start = Shared.Swap(binaryReader.ReadUInt32());
|
get => this.channel2StartOffset;
|
||||||
this.coefficients2Offset = Shared.Swap(binaryReader.ReadUInt32());
|
set => this.channel2StartOffset = value;
|
||||||
this.pad3 = Shared.Swap(binaryReader.ReadUInt32());
|
}
|
||||||
for (int index = 0; index < 16; ++index)
|
|
||||||
this.coefficients1[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
public uint Size
|
||||||
this.channel1Gain = Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.channel1PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.size;
|
||||||
this.channel1PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
set => this.size = value;
|
||||||
this.channel1NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
}
|
||||||
this.channel1LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
|
||||||
this.channel1LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
public ushort SampleRate
|
||||||
this.channel1LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.channel1LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.sampleRate;
|
||||||
for (int index = 0; index < 16; ++index)
|
set => this.sampleRate = value;
|
||||||
this.coefficients2[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
}
|
||||||
this.channel2Gain = Shared.Swap(binaryReader.ReadUInt16());
|
|
||||||
this.channel2PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
public byte ChannelCount
|
||||||
this.channel2PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.channel2NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.channelCount;
|
||||||
this.channel2LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
set => this.channelCount = value;
|
||||||
this.channel2LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
}
|
||||||
this.channel2LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
|
||||||
this.channel2LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
public uint Channel1Start
|
||||||
}
|
{
|
||||||
else
|
get => this.channel1Start;
|
||||||
{
|
set => this.channel1Start = value;
|
||||||
if (this.channelCount != (byte) 1)
|
}
|
||||||
return;
|
|
||||||
for (int index = 0; index < 16; ++index)
|
public uint Channel2Start
|
||||||
this.coefficients1[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.channel1Gain = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.channel2Start;
|
||||||
this.channel1PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
set => this.channel2Start = value;
|
||||||
this.channel1PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
}
|
||||||
this.channel1NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
|
||||||
this.channel1LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
public uint LoopStart
|
||||||
this.channel1LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
{
|
||||||
this.channel1LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
get => this.loopStart;
|
||||||
this.channel1LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
set => this.loopStart = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public uint LoopEnd
|
||||||
|
{
|
||||||
|
get => this.loopEnd;
|
||||||
|
set => this.loopEnd = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] Coefficients1
|
||||||
|
{
|
||||||
|
get => this.coefficients1;
|
||||||
|
set => this.coefficients1 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int[] Coefficients2
|
||||||
|
{
|
||||||
|
get => this.coefficients2;
|
||||||
|
set => this.coefficients2 = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Write(Stream outStream)
|
||||||
|
{
|
||||||
|
outStream.Write(this.magic, 0, this.magic.Length);
|
||||||
|
byte[] bytes1 = BitConverter.GetBytes(this.size);
|
||||||
|
Array.Reverse((Array) bytes1);
|
||||||
|
outStream.Write(bytes1, 0, bytes1.Length);
|
||||||
|
outStream.WriteByte(this.codec);
|
||||||
|
outStream.WriteByte(this.hasLoop);
|
||||||
|
outStream.WriteByte(this.channelCount);
|
||||||
|
outStream.WriteByte(this.zero);
|
||||||
|
byte[] bytes2 = BitConverter.GetBytes(this.sampleRate);
|
||||||
|
Array.Reverse((Array) bytes2);
|
||||||
|
outStream.Write(bytes2, 0, bytes2.Length);
|
||||||
|
byte[] bytes3 = BitConverter.GetBytes(this.pad0);
|
||||||
|
Array.Reverse((Array) bytes3);
|
||||||
|
outStream.Write(bytes3, 0, bytes3.Length);
|
||||||
|
byte[] bytes4 = BitConverter.GetBytes(this.loopStart);
|
||||||
|
Array.Reverse((Array) bytes4);
|
||||||
|
outStream.Write(bytes4, 0, bytes4.Length);
|
||||||
|
byte[] bytes5 = BitConverter.GetBytes(this.loopEnd);
|
||||||
|
Array.Reverse((Array) bytes5);
|
||||||
|
outStream.Write(bytes5, 0, bytes5.Length);
|
||||||
|
byte[] bytes6 = BitConverter.GetBytes(this.offsetToChannelStart);
|
||||||
|
Array.Reverse((Array) bytes6);
|
||||||
|
outStream.Write(bytes6, 0, bytes6.Length);
|
||||||
|
byte[] bytes7 = BitConverter.GetBytes(this.pad1);
|
||||||
|
Array.Reverse((Array) bytes7);
|
||||||
|
outStream.Write(bytes7, 0, bytes7.Length);
|
||||||
|
byte[] bytes8 = BitConverter.GetBytes(this.channel1StartOffset);
|
||||||
|
Array.Reverse((Array) bytes8);
|
||||||
|
outStream.Write(bytes8, 0, bytes8.Length);
|
||||||
|
byte[] bytes9 = BitConverter.GetBytes(this.channel2StartOffset);
|
||||||
|
Array.Reverse((Array) bytes9);
|
||||||
|
outStream.Write(bytes9, 0, bytes9.Length);
|
||||||
|
byte[] bytes10 = BitConverter.GetBytes(this.channel1Start);
|
||||||
|
Array.Reverse((Array) bytes10);
|
||||||
|
outStream.Write(bytes10, 0, bytes10.Length);
|
||||||
|
byte[] bytes11 = BitConverter.GetBytes(this.coefficients1Offset);
|
||||||
|
Array.Reverse((Array) bytes11);
|
||||||
|
outStream.Write(bytes11, 0, bytes11.Length);
|
||||||
|
if (this.channelCount == (byte) 2)
|
||||||
|
{
|
||||||
|
byte[] bytes12 = BitConverter.GetBytes(this.pad2);
|
||||||
|
Array.Reverse((Array) bytes12);
|
||||||
|
outStream.Write(bytes12, 0, bytes12.Length);
|
||||||
|
byte[] bytes13 = BitConverter.GetBytes(this.channel2Start);
|
||||||
|
Array.Reverse((Array) bytes13);
|
||||||
|
outStream.Write(bytes13, 0, bytes13.Length);
|
||||||
|
byte[] bytes14 = BitConverter.GetBytes(this.coefficients2Offset);
|
||||||
|
Array.Reverse((Array) bytes14);
|
||||||
|
outStream.Write(bytes14, 0, bytes14.Length);
|
||||||
|
byte[] bytes15 = BitConverter.GetBytes(this.pad3);
|
||||||
|
Array.Reverse((Array) bytes15);
|
||||||
|
outStream.Write(bytes15, 0, bytes15.Length);
|
||||||
|
foreach (int num in this.coefficients1)
|
||||||
|
{
|
||||||
|
byte[] bytes16 = BitConverter.GetBytes(num);
|
||||||
|
Array.Reverse((Array) bytes16);
|
||||||
|
outStream.Write(bytes16, 2, bytes16.Length - 2);
|
||||||
|
}
|
||||||
|
byte[] bytes17 = BitConverter.GetBytes(this.channel1Gain);
|
||||||
|
Array.Reverse((Array) bytes17);
|
||||||
|
outStream.Write(bytes17, 0, bytes17.Length);
|
||||||
|
byte[] bytes18 = BitConverter.GetBytes(this.channel1PredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes18);
|
||||||
|
outStream.Write(bytes18, 0, bytes18.Length);
|
||||||
|
byte[] bytes19 = BitConverter.GetBytes(this.channel1PreviousValue);
|
||||||
|
Array.Reverse((Array) bytes19);
|
||||||
|
outStream.Write(bytes19, 0, bytes19.Length);
|
||||||
|
byte[] bytes20 = BitConverter.GetBytes(this.channel1NextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes20);
|
||||||
|
outStream.Write(bytes20, 0, bytes20.Length);
|
||||||
|
byte[] bytes21 = BitConverter.GetBytes(this.channel1LoopPredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes21);
|
||||||
|
outStream.Write(bytes21, 0, bytes21.Length);
|
||||||
|
byte[] bytes22 = BitConverter.GetBytes(this.channel1LoopPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes22);
|
||||||
|
outStream.Write(bytes22, 0, bytes22.Length);
|
||||||
|
byte[] bytes23 = BitConverter.GetBytes(this.channel1LoopNextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes23);
|
||||||
|
outStream.Write(bytes23, 0, bytes23.Length);
|
||||||
|
byte[] bytes24 = BitConverter.GetBytes(this.channel1LoopPadding);
|
||||||
|
Array.Reverse((Array) bytes24);
|
||||||
|
outStream.Write(bytes24, 0, bytes24.Length);
|
||||||
|
foreach (int num in this.coefficients2)
|
||||||
|
{
|
||||||
|
byte[] bytes16 = BitConverter.GetBytes(num);
|
||||||
|
Array.Reverse((Array) bytes16);
|
||||||
|
outStream.Write(bytes16, 2, bytes16.Length - 2);
|
||||||
|
}
|
||||||
|
byte[] bytes25 = BitConverter.GetBytes(this.channel2Gain);
|
||||||
|
Array.Reverse((Array) bytes25);
|
||||||
|
outStream.Write(bytes25, 0, bytes25.Length);
|
||||||
|
byte[] bytes26 = BitConverter.GetBytes(this.channel2PredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes26);
|
||||||
|
outStream.Write(bytes26, 0, bytes26.Length);
|
||||||
|
byte[] bytes27 = BitConverter.GetBytes(this.channel2PreviousValue);
|
||||||
|
Array.Reverse((Array) bytes27);
|
||||||
|
outStream.Write(bytes27, 0, bytes27.Length);
|
||||||
|
byte[] bytes28 = BitConverter.GetBytes(this.channel2NextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes28);
|
||||||
|
outStream.Write(bytes28, 0, bytes28.Length);
|
||||||
|
byte[] bytes29 = BitConverter.GetBytes(this.channel2LoopPredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes29);
|
||||||
|
outStream.Write(bytes29, 0, bytes29.Length);
|
||||||
|
byte[] bytes30 = BitConverter.GetBytes(this.channel2LoopPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes30);
|
||||||
|
outStream.Write(bytes30, 0, bytes30.Length);
|
||||||
|
byte[] bytes31 = BitConverter.GetBytes(this.channel2LoopNextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes31);
|
||||||
|
outStream.Write(bytes31, 0, bytes31.Length);
|
||||||
|
byte[] bytes32 = BitConverter.GetBytes(this.channel2LoopPadding);
|
||||||
|
Array.Reverse((Array) bytes32);
|
||||||
|
outStream.Write(bytes32, 0, bytes32.Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.channelCount != (byte) 1)
|
||||||
|
return;
|
||||||
|
foreach (int num in this.coefficients1)
|
||||||
|
{
|
||||||
|
byte[] bytes12 = BitConverter.GetBytes(num);
|
||||||
|
Array.Reverse((Array) bytes12);
|
||||||
|
outStream.Write(bytes12, 2, bytes12.Length - 2);
|
||||||
|
}
|
||||||
|
byte[] bytes13 = BitConverter.GetBytes(this.channel1Gain);
|
||||||
|
Array.Reverse((Array) bytes13);
|
||||||
|
outStream.Write(bytes13, 0, bytes13.Length);
|
||||||
|
byte[] bytes14 = BitConverter.GetBytes(this.channel1PredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes14);
|
||||||
|
outStream.Write(bytes14, 0, bytes14.Length);
|
||||||
|
byte[] bytes15 = BitConverter.GetBytes(this.channel1PreviousValue);
|
||||||
|
Array.Reverse((Array) bytes15);
|
||||||
|
outStream.Write(bytes15, 0, bytes15.Length);
|
||||||
|
byte[] bytes16 = BitConverter.GetBytes(this.channel1NextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes16);
|
||||||
|
outStream.Write(bytes16, 0, bytes16.Length);
|
||||||
|
byte[] bytes17 = BitConverter.GetBytes(this.channel1LoopPredictiveScale);
|
||||||
|
Array.Reverse((Array) bytes17);
|
||||||
|
outStream.Write(bytes17, 0, bytes17.Length);
|
||||||
|
byte[] bytes18 = BitConverter.GetBytes(this.channel1LoopPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes18);
|
||||||
|
outStream.Write(bytes18, 0, bytes18.Length);
|
||||||
|
byte[] bytes19 = BitConverter.GetBytes(this.channel1LoopNextPreviousValue);
|
||||||
|
Array.Reverse((Array) bytes19);
|
||||||
|
outStream.Write(bytes19, 0, bytes19.Length);
|
||||||
|
byte[] bytes20 = BitConverter.GetBytes(this.channel1LoopPadding);
|
||||||
|
Array.Reverse((Array) bytes20);
|
||||||
|
outStream.Write(bytes20, 0, bytes20.Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Read(Stream input)
|
||||||
|
{
|
||||||
|
BinaryReader binaryReader = new BinaryReader(input);
|
||||||
|
this.size = Shared.CompareByteArrays(this.magic, binaryReader.ReadBytes(4)) ? Shared.Swap(binaryReader.ReadUInt32()) : throw new Exception("This is not a valid BNS audfo file!");
|
||||||
|
this.codec = binaryReader.ReadByte();
|
||||||
|
this.hasLoop = binaryReader.ReadByte();
|
||||||
|
this.channelCount = binaryReader.ReadByte();
|
||||||
|
this.zero = binaryReader.ReadByte();
|
||||||
|
this.sampleRate = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.pad0 = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.loopStart = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.loopEnd = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.offsetToChannelStart = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.pad1 = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.channel1StartOffset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.channel2StartOffset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.channel1Start = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.coefficients1Offset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
if (this.channelCount == (byte) 2)
|
||||||
|
{
|
||||||
|
this.pad2 = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.channel2Start = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.coefficients2Offset = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
this.pad3 = Shared.Swap(binaryReader.ReadUInt32());
|
||||||
|
for (int index = 0; index < 16; ++index)
|
||||||
|
this.coefficients1[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1Gain = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
for (int index = 0; index < 16; ++index)
|
||||||
|
this.coefficients2[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2Gain = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel2LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (this.channelCount != (byte) 1)
|
||||||
|
return;
|
||||||
|
for (int index = 0; index < 16; ++index)
|
||||||
|
this.coefficients1[index] = (int) (short) Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1Gain = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1PredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1PreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1NextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPredictiveScale = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopNextPreviousValue = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
this.channel1LoopPadding = Shared.Swap(binaryReader.ReadUInt16());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
118
Brlan.cs
118
Brlan.cs
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.Brlan
|
* 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;
|
||||||
|
@ -10,57 +22,57 @@ using System.IO;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
public class Brlan
|
public class Brlan
|
||||||
{
|
|
||||||
public static string[] GetBrlanTpls(string pathTobrlan) => Brlan.getBrlanTpls(File.ReadAllBytes(pathTobrlan));
|
|
||||||
|
|
||||||
public static string[] GetBrlanTpls(byte[] brlanFile) => Brlan.getBrlanTpls(brlanFile);
|
|
||||||
|
|
||||||
public static string[] GetBrlanTpls(WAD wad, bool banner)
|
|
||||||
{
|
{
|
||||||
if (!wad.HasBanner)
|
public static string[] GetBrlanTpls(string pathTobrlan) => Brlan.getBrlanTpls(File.ReadAllBytes(pathTobrlan));
|
||||||
return new string[0];
|
|
||||||
string str = nameof (banner);
|
public static string[] GetBrlanTpls(byte[] brlanFile) => Brlan.getBrlanTpls(brlanFile);
|
||||||
if (!banner)
|
|
||||||
str = "icon";
|
public static string[] GetBrlanTpls(WAD wad, bool banner)
|
||||||
for (int index1 = 0; index1 < wad.BannerApp.Nodes.Count; ++index1)
|
|
||||||
{
|
|
||||||
if (wad.BannerApp.StringTable[index1].ToLower() == str + ".bin")
|
|
||||||
{
|
{
|
||||||
U8 u8 = U8.Load(wad.BannerApp.Data[index1]);
|
if (!wad.HasBanner)
|
||||||
string[] a = new string[0];
|
return new string[0];
|
||||||
for (int index2 = 0; index2 < u8.Nodes.Count; ++index2)
|
string str = nameof (banner);
|
||||||
{
|
if (!banner)
|
||||||
if (u8.StringTable[index2].ToLower() == str + "_start.brlan" || u8.StringTable[index2].ToLower() == str + "_loop.brlan" || u8.StringTable[index2].ToLower() == str + ".brlan")
|
str = "icon";
|
||||||
a = Shared.MergeStringArrays(a, Brlan.getBrlanTpls(u8.Data[index2]));
|
for (int index1 = 0; index1 < wad.BannerApp.Nodes.Count; ++index1)
|
||||||
}
|
{
|
||||||
return a;
|
if (wad.BannerApp.StringTable[index1].ToLower() == str + ".bin")
|
||||||
|
{
|
||||||
|
U8 u8 = U8.Load(wad.BannerApp.Data[index1]);
|
||||||
|
string[] a = new string[0];
|
||||||
|
for (int index2 = 0; index2 < u8.Nodes.Count; ++index2)
|
||||||
|
{
|
||||||
|
if (u8.StringTable[index2].ToLower() == str + "_start.brlan" || u8.StringTable[index2].ToLower() == str + "_loop.brlan" || u8.StringTable[index2].ToLower() == str + ".brlan")
|
||||||
|
a = Shared.MergeStringArrays(a, Brlan.getBrlanTpls(u8.Data[index2]));
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new string[0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new string[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string[] getBrlanTpls(byte[] brlanFile)
|
private static string[] getBrlanTpls(byte[] brlanFile)
|
||||||
{
|
{
|
||||||
List<string> stringList = new List<string>();
|
List<string> stringList = new List<string>();
|
||||||
int numOfTpls = Brlan.getNumOfTpls(brlanFile);
|
int numOfTpls = Brlan.getNumOfTpls(brlanFile);
|
||||||
int index1 = 36 + numOfTpls * 4;
|
int index1 = 36 + numOfTpls * 4;
|
||||||
for (int index2 = 0; index2 < numOfTpls; ++index2)
|
for (int index2 = 0; index2 < numOfTpls; ++index2)
|
||||||
{
|
{
|
||||||
string empty = string.Empty;
|
string empty = string.Empty;
|
||||||
while (brlanFile[index1] != (byte) 0)
|
while (brlanFile[index1] != (byte) 0)
|
||||||
empty += Convert.ToChar(brlanFile[index1++]).ToString();
|
empty += Convert.ToChar(brlanFile[index1++]).ToString();
|
||||||
stringList.Add(empty);
|
stringList.Add(empty);
|
||||||
++index1;
|
++index1;
|
||||||
}
|
}
|
||||||
for (int index2 = stringList.Count - 1; index2 >= 0; --index2)
|
for (int index2 = stringList.Count - 1; index2 >= 0; --index2)
|
||||||
{
|
{
|
||||||
if (!stringList[index2].ToLower().EndsWith(".tpl"))
|
if (!stringList[index2].ToLower().EndsWith(".tpl"))
|
||||||
stringList.RemoveAt(index2);
|
stringList.RemoveAt(index2);
|
||||||
}
|
}
|
||||||
return stringList.ToArray();
|
return stringList.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getNumOfTpls(byte[] brlanFile) => (int) Shared.Swap(BitConverter.ToUInt16(brlanFile, 28));
|
private static int getNumOfTpls(byte[] brlanFile) => (int) Shared.Swap(BitConverter.ToUInt16(brlanFile, 28));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
118
Brlyt.cs
118
Brlyt.cs
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.Brlyt
|
* 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;
|
||||||
|
@ -10,57 +22,57 @@ using System.IO;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
public class Brlyt
|
public class Brlyt
|
||||||
{
|
|
||||||
public static string[] GetBrlytTpls(string pathToBrlyt) => Brlyt.getBrlytTpls(File.ReadAllBytes(pathToBrlyt));
|
|
||||||
|
|
||||||
public static string[] GetBrlytTpls(byte[] brlytFile) => Brlyt.getBrlytTpls(brlytFile);
|
|
||||||
|
|
||||||
public static string[] GetBrlytTpls(WAD wad, bool banner)
|
|
||||||
{
|
{
|
||||||
if (!wad.HasBanner)
|
public static string[] GetBrlytTpls(string pathToBrlyt) => Brlyt.getBrlytTpls(File.ReadAllBytes(pathToBrlyt));
|
||||||
return new string[0];
|
|
||||||
string str = nameof (banner);
|
public static string[] GetBrlytTpls(byte[] brlytFile) => Brlyt.getBrlytTpls(brlytFile);
|
||||||
if (!banner)
|
|
||||||
str = "icon";
|
public static string[] GetBrlytTpls(WAD wad, bool banner)
|
||||||
for (int index1 = 0; index1 < wad.BannerApp.Nodes.Count; ++index1)
|
|
||||||
{
|
|
||||||
if (wad.BannerApp.StringTable[index1].ToLower() == str + ".bin")
|
|
||||||
{
|
{
|
||||||
U8 u8 = U8.Load(wad.BannerApp.Data[index1]);
|
if (!wad.HasBanner)
|
||||||
string[] a = new string[0];
|
return new string[0];
|
||||||
for (int index2 = 0; index2 < u8.Nodes.Count; ++index2)
|
string str = nameof (banner);
|
||||||
{
|
if (!banner)
|
||||||
if (u8.StringTable[index2].ToLower() == str + ".brlyt")
|
str = "icon";
|
||||||
a = Shared.MergeStringArrays(a, Brlyt.getBrlytTpls(u8.Data[index2]));
|
for (int index1 = 0; index1 < wad.BannerApp.Nodes.Count; ++index1)
|
||||||
}
|
{
|
||||||
return a;
|
if (wad.BannerApp.StringTable[index1].ToLower() == str + ".bin")
|
||||||
|
{
|
||||||
|
U8 u8 = U8.Load(wad.BannerApp.Data[index1]);
|
||||||
|
string[] a = new string[0];
|
||||||
|
for (int index2 = 0; index2 < u8.Nodes.Count; ++index2)
|
||||||
|
{
|
||||||
|
if (u8.StringTable[index2].ToLower() == str + ".brlyt")
|
||||||
|
a = Shared.MergeStringArrays(a, Brlyt.getBrlytTpls(u8.Data[index2]));
|
||||||
|
}
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new string[0];
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return new string[0];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string[] getBrlytTpls(byte[] brlytFile)
|
private static string[] getBrlytTpls(byte[] brlytFile)
|
||||||
{
|
{
|
||||||
List<string> stringList = new List<string>();
|
List<string> stringList = new List<string>();
|
||||||
int numOfTpls = Brlyt.getNumOfTpls(brlytFile);
|
int numOfTpls = Brlyt.getNumOfTpls(brlytFile);
|
||||||
int index1 = 48 + numOfTpls * 8;
|
int index1 = 48 + numOfTpls * 8;
|
||||||
for (int index2 = 0; index2 < numOfTpls; ++index2)
|
for (int index2 = 0; index2 < numOfTpls; ++index2)
|
||||||
{
|
{
|
||||||
string empty = string.Empty;
|
string empty = string.Empty;
|
||||||
while (brlytFile[index1] != (byte) 0)
|
while (brlytFile[index1] != (byte) 0)
|
||||||
empty += Convert.ToChar(brlytFile[index1++]).ToString();
|
empty += Convert.ToChar(brlytFile[index1++]).ToString();
|
||||||
stringList.Add(empty);
|
stringList.Add(empty);
|
||||||
++index1;
|
++index1;
|
||||||
}
|
}
|
||||||
for (int index2 = stringList.Count - 1; index2 >= 0; --index2)
|
for (int index2 = stringList.Count - 1; index2 >= 0; --index2)
|
||||||
{
|
{
|
||||||
if (!stringList[index2].ToLower().EndsWith(".tpl"))
|
if (!stringList[index2].ToLower().EndsWith(".tpl"))
|
||||||
stringList.RemoveAt(index2);
|
stringList.RemoveAt(index2);
|
||||||
}
|
}
|
||||||
return stringList.ToArray();
|
return stringList.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getNumOfTpls(byte[] brlytFile) => (int) Shared.Swap(BitConverter.ToUInt16(brlytFile, 44));
|
private static int getNumOfTpls(byte[] brlytFile) => (int) Shared.Swap(BitConverter.ToUInt16(brlytFile, 44));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,20 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.CertificateChain
|
* 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;
|
||||||
|
@ -10,429 +22,429 @@ using System.Security.Cryptography;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
public class CertificateChain : IDisposable
|
public class CertificateChain : IDisposable
|
||||||
{
|
|
||||||
private const string certCaHash = "5B7D3EE28706AD8DA2CBD5A6B75C15D0F9B6F318";
|
|
||||||
private const string certCpHash = "6824D6DA4C25184F0D6DAF6EDB9C0FC57522A41C";
|
|
||||||
private const string certXsHash = "09787045037121477824BC6A3E5E076156573F8A";
|
|
||||||
private SHA1 sha = SHA1.Create();
|
|
||||||
private bool[] certsComplete = new bool[3];
|
|
||||||
private byte[] certCa = new byte[1024];
|
|
||||||
private byte[] certCp = new byte[768];
|
|
||||||
private byte[] certXs = new byte[768];
|
|
||||||
private bool isDisposed;
|
|
||||||
|
|
||||||
public bool CertsComplete => this.certsComplete[0] && this.certsComplete[1] && this.certsComplete[2];
|
|
||||||
|
|
||||||
public event EventHandler<MessageEventArgs> Debug;
|
|
||||||
|
|
||||||
~CertificateChain() => this.Dispose(false);
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
{
|
||||||
this.Dispose(true);
|
private const string certCaHash = "5B7D3EE28706AD8DA2CBD5A6B75C15D0F9B6F318";
|
||||||
GC.SuppressFinalize((object) this);
|
private const string certCpHash = "6824D6DA4C25184F0D6DAF6EDB9C0FC57522A41C";
|
||||||
}
|
private const string certXsHash = "09787045037121477824BC6A3E5E076156573F8A";
|
||||||
|
private SHA1 sha = SHA1.Create();
|
||||||
|
private bool[] certsComplete = new bool[3];
|
||||||
|
private byte[] certCa = new byte[1024];
|
||||||
|
private byte[] certCp = new byte[768];
|
||||||
|
private byte[] certXs = new byte[768];
|
||||||
|
private bool isDisposed;
|
||||||
|
|
||||||
protected virtual void Dispose(bool disposing)
|
public bool CertsComplete => this.certsComplete[0] && this.certsComplete[1] && this.certsComplete[2];
|
||||||
{
|
|
||||||
if (disposing && !this.isDisposed)
|
|
||||||
{
|
|
||||||
this.sha.Clear();
|
|
||||||
this.sha = (SHA1) null;
|
|
||||||
this.certsComplete = (bool[]) null;
|
|
||||||
this.certCa = (byte[]) null;
|
|
||||||
this.certCp = (byte[]) null;
|
|
||||||
this.certXs = (byte[]) null;
|
|
||||||
}
|
|
||||||
this.isDisposed = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CertificateChain Load(string pathToCert) => CertificateChain.Load(File.ReadAllBytes(pathToCert));
|
public event EventHandler<MessageEventArgs> Debug;
|
||||||
|
|
||||||
public static CertificateChain Load(byte[] certFile)
|
~CertificateChain() => this.Dispose(false);
|
||||||
{
|
|
||||||
CertificateChain certificateChain = new CertificateChain();
|
|
||||||
MemoryStream memoryStream = new MemoryStream(certFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
certificateChain.parseCert((Stream) memoryStream);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
memoryStream.Dispose();
|
|
||||||
return certificateChain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CertificateChain Load(Stream cert)
|
public void Dispose()
|
||||||
{
|
|
||||||
CertificateChain certificateChain = new CertificateChain();
|
|
||||||
certificateChain.parseCert(cert);
|
|
||||||
return certificateChain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CertificateChain FromTikTmd(string pathToTik, string pathToTmd) => CertificateChain.FromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd));
|
|
||||||
|
|
||||||
public static CertificateChain FromTikTmd(byte[] tikFile, byte[] tmdFile)
|
|
||||||
{
|
|
||||||
CertificateChain certificateChain = new CertificateChain();
|
|
||||||
MemoryStream memoryStream1 = new MemoryStream(tikFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
certificateChain.grabFromTik((Stream) memoryStream1);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream1.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
MemoryStream memoryStream2 = new MemoryStream(tmdFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
certificateChain.grabFromTmd((Stream) memoryStream2);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream2.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
memoryStream2.Dispose();
|
|
||||||
return certificateChain.CertsComplete ? certificateChain : throw new Exception("Couldn't locate all certs!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CertificateChain FromTikTmd(Stream tik, Stream tmd)
|
|
||||||
{
|
|
||||||
CertificateChain certificateChain = new CertificateChain();
|
|
||||||
certificateChain.grabFromTik(tik);
|
|
||||||
certificateChain.grabFromTmd(tmd);
|
|
||||||
return certificateChain;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFile(string pathToCert) => this.LoadFile(File.ReadAllBytes(pathToCert));
|
|
||||||
|
|
||||||
public void LoadFile(byte[] certFile)
|
|
||||||
{
|
|
||||||
MemoryStream memoryStream = new MemoryStream(certFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.parseCert((Stream) memoryStream);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
memoryStream.Dispose();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFile(Stream cert) => this.parseCert(cert);
|
|
||||||
|
|
||||||
public void LoadFromTikTmd(string pathToTik, string pathToTmd) => this.LoadFromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd));
|
|
||||||
|
|
||||||
public void LoadFromTikTmd(byte[] tikFile, byte[] tmdFile)
|
|
||||||
{
|
|
||||||
MemoryStream memoryStream1 = new MemoryStream(tikFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.grabFromTik((Stream) memoryStream1);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream1.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
MemoryStream memoryStream2 = new MemoryStream(tmdFile);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.grabFromTmd((Stream) memoryStream2);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream2.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
memoryStream2.Dispose();
|
|
||||||
if (!this.CertsComplete)
|
|
||||||
throw new Exception("Couldn't locate all certs!");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void LoadFromTikTmd(Stream tik, Stream tmd)
|
|
||||||
{
|
|
||||||
this.grabFromTik(tik);
|
|
||||||
this.grabFromTmd(tmd);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Save(string savePath)
|
|
||||||
{
|
|
||||||
if (File.Exists(savePath))
|
|
||||||
File.Delete(savePath);
|
|
||||||
using (FileStream fileStream = new FileStream(savePath, FileMode.Create))
|
|
||||||
this.writeToStream((Stream) fileStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
public MemoryStream ToMemoryStream()
|
|
||||||
{
|
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.writeToStream((Stream) memoryStream);
|
|
||||||
return memoryStream;
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public byte[] ToByteArray()
|
|
||||||
{
|
|
||||||
MemoryStream memoryStream = new MemoryStream();
|
|
||||||
try
|
|
||||||
{
|
|
||||||
this.writeToStream((Stream) memoryStream);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
memoryStream.Dispose();
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
byte[] array = memoryStream.ToArray();
|
|
||||||
memoryStream.Dispose();
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void writeToStream(Stream writeStream)
|
|
||||||
{
|
|
||||||
this.fireDebug("Writing Certificate Chain...");
|
|
||||||
if (!this.CertsComplete)
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate Chain incomplete...");
|
|
||||||
throw new Exception("At least one certificate is missing!");
|
|
||||||
}
|
|
||||||
writeStream.Seek(0L, SeekOrigin.Begin);
|
|
||||||
object[] objArray1 = new object[1];
|
|
||||||
long position = writeStream.Position;
|
|
||||||
objArray1[0] = (object) position.ToString("x8");
|
|
||||||
this.fireDebug(" Writing Certificate CA... (Offset: 0x{0})", objArray1);
|
|
||||||
writeStream.Write(this.certCa, 0, this.certCa.Length);
|
|
||||||
object[] objArray2 = new object[1];
|
|
||||||
position = writeStream.Position;
|
|
||||||
objArray2[0] = (object) position.ToString("x8");
|
|
||||||
this.fireDebug(" Writing Certificate CP... (Offset: 0x{0})", objArray2);
|
|
||||||
writeStream.Write(this.certCp, 0, this.certCp.Length);
|
|
||||||
object[] objArray3 = new object[1];
|
|
||||||
position = writeStream.Position;
|
|
||||||
objArray3[0] = (object) position.ToString("x8");
|
|
||||||
this.fireDebug(" Writing Certificate XS... (Offset: 0x{0})", objArray3);
|
|
||||||
writeStream.Write(this.certXs, 0, this.certXs.Length);
|
|
||||||
this.fireDebug("Writing Certificate Chain Finished...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseCert(Stream certFile)
|
|
||||||
{
|
|
||||||
this.fireDebug("Parsing Certificate Chain...");
|
|
||||||
int num = 0;
|
|
||||||
for (int index = 0; index < 3; ++index)
|
|
||||||
{
|
|
||||||
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
certFile.Seek((long) num, SeekOrigin.Begin);
|
this.Dispose(true);
|
||||||
byte[] array = new byte[1024];
|
GC.SuppressFinalize((object) this);
|
||||||
certFile.Read(array, 0, array.Length);
|
}
|
||||||
this.fireDebug(" Checking for Certificate CA...");
|
|
||||||
if (this.isCertCa(array) && !this.certsComplete[1])
|
protected virtual void Dispose(bool disposing)
|
||||||
{
|
{
|
||||||
this.fireDebug(" Certificate CA detected...");
|
if (disposing && !this.isDisposed)
|
||||||
this.certCa = array;
|
|
||||||
this.certsComplete[1] = true;
|
|
||||||
num += 1024;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate CP...");
|
|
||||||
if (this.isCertCp(array) && !this.certsComplete[2])
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate CP detected...");
|
|
||||||
Array.Resize<byte>(ref array, 768);
|
|
||||||
this.certCp = array;
|
|
||||||
this.certsComplete[2] = true;
|
|
||||||
num += 768;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate XS...");
|
|
||||||
if (this.isCertXs(array))
|
|
||||||
{
|
|
||||||
if (!this.certsComplete[0])
|
|
||||||
{
|
{
|
||||||
this.fireDebug(" Certificate XS detected...");
|
this.sha.Clear();
|
||||||
Array.Resize<byte>(ref array, 768);
|
this.sha = (SHA1) null;
|
||||||
this.certXs = array;
|
this.certsComplete = (bool[]) null;
|
||||||
this.certsComplete[0] = true;
|
this.certCa = (byte[]) null;
|
||||||
num += 768;
|
this.certCp = (byte[]) null;
|
||||||
continue;
|
this.certXs = (byte[]) null;
|
||||||
}
|
}
|
||||||
}
|
this.isDisposed = true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
this.fireDebug("Error: {0}", (object) ex.Message);
|
|
||||||
}
|
|
||||||
num += 768;
|
|
||||||
}
|
|
||||||
if (!this.CertsComplete)
|
|
||||||
{
|
|
||||||
this.fireDebug(" Couldn't locate all Certificates...");
|
|
||||||
throw new Exception("Couldn't locate all certs!");
|
|
||||||
}
|
|
||||||
this.fireDebug("Parsing Certificate Chain Finished...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void grabFromTik(Stream tik)
|
public static CertificateChain Load(string pathToCert) => CertificateChain.Load(File.ReadAllBytes(pathToCert));
|
||||||
{
|
|
||||||
this.fireDebug("Scanning Ticket for Certificates...");
|
public static CertificateChain Load(byte[] certFile)
|
||||||
int num = 676;
|
|
||||||
for (int index = 0; index < 3; ++index)
|
|
||||||
{
|
|
||||||
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
|
||||||
try
|
|
||||||
{
|
{
|
||||||
tik.Seek((long) num, SeekOrigin.Begin);
|
CertificateChain certificateChain = new CertificateChain();
|
||||||
byte[] array = new byte[1024];
|
MemoryStream memoryStream = new MemoryStream(certFile);
|
||||||
tik.Read(array, 0, array.Length);
|
try
|
||||||
this.fireDebug(" Checking for Certificate CA...");
|
|
||||||
if (this.isCertCa(array) && !this.certsComplete[1])
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate CA detected...");
|
|
||||||
this.certCa = array;
|
|
||||||
this.certsComplete[1] = true;
|
|
||||||
num += 1024;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate CP...");
|
|
||||||
if (this.isCertCp(array) && !this.certsComplete[2])
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate CP detected...");
|
|
||||||
Array.Resize<byte>(ref array, 768);
|
|
||||||
this.certCp = array;
|
|
||||||
this.certsComplete[2] = true;
|
|
||||||
num += 768;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate XS...");
|
|
||||||
if (this.isCertXs(array))
|
|
||||||
{
|
|
||||||
if (!this.certsComplete[0])
|
|
||||||
{
|
{
|
||||||
this.fireDebug(" Certificate XS detected...");
|
certificateChain.parseCert((Stream) memoryStream);
|
||||||
Array.Resize<byte>(ref array, 768);
|
|
||||||
this.certXs = array;
|
|
||||||
this.certsComplete[0] = true;
|
|
||||||
num += 768;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
catch
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
}
|
|
||||||
num += 768;
|
|
||||||
}
|
|
||||||
this.fireDebug("Scanning Ticket for Certificates Finished...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void grabFromTmd(Stream tmd)
|
|
||||||
{
|
|
||||||
this.fireDebug("Scanning TMD for Certificates...");
|
|
||||||
byte[] buffer = new byte[2];
|
|
||||||
tmd.Seek(478L, SeekOrigin.Begin);
|
|
||||||
tmd.Read(buffer, 0, 2);
|
|
||||||
int num = 484 + (int) Shared.Swap(BitConverter.ToUInt16(buffer, 0)) * 36;
|
|
||||||
for (int index = 0; index < 3; ++index)
|
|
||||||
{
|
|
||||||
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
|
||||||
try
|
|
||||||
{
|
|
||||||
tmd.Seek((long) num, SeekOrigin.Begin);
|
|
||||||
byte[] array = new byte[1024];
|
|
||||||
tmd.Read(array, 0, array.Length);
|
|
||||||
this.fireDebug(" Checking for Certificate CA...");
|
|
||||||
if (this.isCertCa(array) && !this.certsComplete[1])
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate CA detected...");
|
|
||||||
this.certCa = array;
|
|
||||||
this.certsComplete[1] = true;
|
|
||||||
num += 1024;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate CP...");
|
|
||||||
if (this.isCertCp(array) && !this.certsComplete[2])
|
|
||||||
{
|
|
||||||
this.fireDebug(" Certificate CP detected...");
|
|
||||||
Array.Resize<byte>(ref array, 768);
|
|
||||||
this.certCp = array;
|
|
||||||
this.certsComplete[2] = true;
|
|
||||||
num += 768;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
this.fireDebug(" Checking for Certificate XS...");
|
|
||||||
if (this.isCertXs(array))
|
|
||||||
{
|
|
||||||
if (!this.certsComplete[0])
|
|
||||||
{
|
{
|
||||||
this.fireDebug(" Certificate XS detected...");
|
memoryStream.Dispose();
|
||||||
Array.Resize<byte>(ref array, 768);
|
throw;
|
||||||
this.certXs = array;
|
|
||||||
this.certsComplete[0] = true;
|
|
||||||
num += 768;
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
memoryStream.Dispose();
|
||||||
|
return certificateChain;
|
||||||
}
|
}
|
||||||
catch
|
|
||||||
|
public static CertificateChain Load(Stream cert)
|
||||||
{
|
{
|
||||||
|
CertificateChain certificateChain = new CertificateChain();
|
||||||
|
certificateChain.parseCert(cert);
|
||||||
|
return certificateChain;
|
||||||
}
|
}
|
||||||
num += 768;
|
|
||||||
}
|
|
||||||
this.fireDebug("Scanning TMD for Certificates Finished...");
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool isCertXs(byte[] part)
|
public static CertificateChain FromTikTmd(string pathToTik, string pathToTmd) => CertificateChain.FromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd));
|
||||||
{
|
|
||||||
if (part.Length < 768)
|
|
||||||
return false;
|
|
||||||
if (part.Length > 768)
|
|
||||||
Array.Resize<byte>(ref part, 768);
|
|
||||||
return part[388] == (byte) 88 && part[389] == (byte) 83 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("09787045037121477824BC6A3E5E076156573F8A"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool isCertCa(byte[] part)
|
public static CertificateChain FromTikTmd(byte[] tikFile, byte[] tmdFile)
|
||||||
{
|
{
|
||||||
if (part.Length < 1024)
|
CertificateChain certificateChain = new CertificateChain();
|
||||||
return false;
|
MemoryStream memoryStream1 = new MemoryStream(tikFile);
|
||||||
if (part.Length > 1024)
|
try
|
||||||
Array.Resize<byte>(ref part, 1024);
|
{
|
||||||
return part[644] == (byte) 67 && part[645] == (byte) 65 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("5B7D3EE28706AD8DA2CBD5A6B75C15D0F9B6F318"));
|
certificateChain.grabFromTik((Stream) memoryStream1);
|
||||||
}
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream1.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
MemoryStream memoryStream2 = new MemoryStream(tmdFile);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
certificateChain.grabFromTmd((Stream) memoryStream2);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream2.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
memoryStream2.Dispose();
|
||||||
|
return certificateChain.CertsComplete ? certificateChain : throw new Exception("Couldn't locate all certs!");
|
||||||
|
}
|
||||||
|
|
||||||
private bool isCertCp(byte[] part)
|
public static CertificateChain FromTikTmd(Stream tik, Stream tmd)
|
||||||
{
|
{
|
||||||
if (part.Length < 768)
|
CertificateChain certificateChain = new CertificateChain();
|
||||||
return false;
|
certificateChain.grabFromTik(tik);
|
||||||
if (part.Length > 768)
|
certificateChain.grabFromTmd(tmd);
|
||||||
Array.Resize<byte>(ref part, 768);
|
return certificateChain;
|
||||||
return part[388] == (byte) 67 && part[389] == (byte) 80 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("6824D6DA4C25184F0D6DAF6EDB9C0FC57522A41C"));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void fireDebug(string debugMessage, params object[] args)
|
public void LoadFile(string pathToCert) => this.LoadFile(File.ReadAllBytes(pathToCert));
|
||||||
{
|
|
||||||
EventHandler<MessageEventArgs> debug = this.Debug;
|
public void LoadFile(byte[] certFile)
|
||||||
if (debug == null)
|
{
|
||||||
return;
|
MemoryStream memoryStream = new MemoryStream(certFile);
|
||||||
debug(new object(), new MessageEventArgs(string.Format(debugMessage, args)));
|
try
|
||||||
|
{
|
||||||
|
this.parseCert((Stream) memoryStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
memoryStream.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFile(Stream cert) => this.parseCert(cert);
|
||||||
|
|
||||||
|
public void LoadFromTikTmd(string pathToTik, string pathToTmd) => this.LoadFromTikTmd(File.ReadAllBytes(pathToTik), File.ReadAllBytes(pathToTmd));
|
||||||
|
|
||||||
|
public void LoadFromTikTmd(byte[] tikFile, byte[] tmdFile)
|
||||||
|
{
|
||||||
|
MemoryStream memoryStream1 = new MemoryStream(tikFile);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.grabFromTik((Stream) memoryStream1);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream1.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
MemoryStream memoryStream2 = new MemoryStream(tmdFile);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.grabFromTmd((Stream) memoryStream2);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream2.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
memoryStream2.Dispose();
|
||||||
|
if (!this.CertsComplete)
|
||||||
|
throw new Exception("Couldn't locate all certs!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LoadFromTikTmd(Stream tik, Stream tmd)
|
||||||
|
{
|
||||||
|
this.grabFromTik(tik);
|
||||||
|
this.grabFromTmd(tmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Save(string savePath)
|
||||||
|
{
|
||||||
|
if (File.Exists(savePath))
|
||||||
|
File.Delete(savePath);
|
||||||
|
using (FileStream fileStream = new FileStream(savePath, FileMode.Create))
|
||||||
|
this.writeToStream((Stream) fileStream);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemoryStream ToMemoryStream()
|
||||||
|
{
|
||||||
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.writeToStream((Stream) memoryStream);
|
||||||
|
return memoryStream;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte[] ToByteArray()
|
||||||
|
{
|
||||||
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
this.writeToStream((Stream) memoryStream);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
memoryStream.Dispose();
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
byte[] array = memoryStream.ToArray();
|
||||||
|
memoryStream.Dispose();
|
||||||
|
return array;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeToStream(Stream writeStream)
|
||||||
|
{
|
||||||
|
this.fireDebug("Writing Certificate Chain...");
|
||||||
|
if (!this.CertsComplete)
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate Chain incomplete...");
|
||||||
|
throw new Exception("At least one certificate is missing!");
|
||||||
|
}
|
||||||
|
writeStream.Seek(0L, SeekOrigin.Begin);
|
||||||
|
object[] objArray1 = new object[1];
|
||||||
|
long position = writeStream.Position;
|
||||||
|
objArray1[0] = (object) position.ToString("x8");
|
||||||
|
this.fireDebug(" Writing Certificate CA... (Offset: 0x{0})", objArray1);
|
||||||
|
writeStream.Write(this.certCa, 0, this.certCa.Length);
|
||||||
|
object[] objArray2 = new object[1];
|
||||||
|
position = writeStream.Position;
|
||||||
|
objArray2[0] = (object) position.ToString("x8");
|
||||||
|
this.fireDebug(" Writing Certificate CP... (Offset: 0x{0})", objArray2);
|
||||||
|
writeStream.Write(this.certCp, 0, this.certCp.Length);
|
||||||
|
object[] objArray3 = new object[1];
|
||||||
|
position = writeStream.Position;
|
||||||
|
objArray3[0] = (object) position.ToString("x8");
|
||||||
|
this.fireDebug(" Writing Certificate XS... (Offset: 0x{0})", objArray3);
|
||||||
|
writeStream.Write(this.certXs, 0, this.certXs.Length);
|
||||||
|
this.fireDebug("Writing Certificate Chain Finished...");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseCert(Stream certFile)
|
||||||
|
{
|
||||||
|
this.fireDebug("Parsing Certificate Chain...");
|
||||||
|
int num = 0;
|
||||||
|
for (int index = 0; index < 3; ++index)
|
||||||
|
{
|
||||||
|
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
certFile.Seek((long) num, SeekOrigin.Begin);
|
||||||
|
byte[] array = new byte[1024];
|
||||||
|
certFile.Read(array, 0, array.Length);
|
||||||
|
this.fireDebug(" Checking for Certificate CA...");
|
||||||
|
if (this.isCertCa(array) && !this.certsComplete[1])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CA detected...");
|
||||||
|
this.certCa = array;
|
||||||
|
this.certsComplete[1] = true;
|
||||||
|
num += 1024;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate CP...");
|
||||||
|
if (this.isCertCp(array) && !this.certsComplete[2])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CP detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certCp = array;
|
||||||
|
this.certsComplete[2] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate XS...");
|
||||||
|
if (this.isCertXs(array))
|
||||||
|
{
|
||||||
|
if (!this.certsComplete[0])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate XS detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certXs = array;
|
||||||
|
this.certsComplete[0] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
this.fireDebug("Error: {0}", (object) ex.Message);
|
||||||
|
}
|
||||||
|
num += 768;
|
||||||
|
}
|
||||||
|
if (!this.CertsComplete)
|
||||||
|
{
|
||||||
|
this.fireDebug(" Couldn't locate all Certificates...");
|
||||||
|
throw new Exception("Couldn't locate all certs!");
|
||||||
|
}
|
||||||
|
this.fireDebug("Parsing Certificate Chain Finished...");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void grabFromTik(Stream tik)
|
||||||
|
{
|
||||||
|
this.fireDebug("Scanning Ticket for Certificates...");
|
||||||
|
int num = 676;
|
||||||
|
for (int index = 0; index < 3; ++index)
|
||||||
|
{
|
||||||
|
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tik.Seek((long) num, SeekOrigin.Begin);
|
||||||
|
byte[] array = new byte[1024];
|
||||||
|
tik.Read(array, 0, array.Length);
|
||||||
|
this.fireDebug(" Checking for Certificate CA...");
|
||||||
|
if (this.isCertCa(array) && !this.certsComplete[1])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CA detected...");
|
||||||
|
this.certCa = array;
|
||||||
|
this.certsComplete[1] = true;
|
||||||
|
num += 1024;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate CP...");
|
||||||
|
if (this.isCertCp(array) && !this.certsComplete[2])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CP detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certCp = array;
|
||||||
|
this.certsComplete[2] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate XS...");
|
||||||
|
if (this.isCertXs(array))
|
||||||
|
{
|
||||||
|
if (!this.certsComplete[0])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate XS detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certXs = array;
|
||||||
|
this.certsComplete[0] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
num += 768;
|
||||||
|
}
|
||||||
|
this.fireDebug("Scanning Ticket for Certificates Finished...");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void grabFromTmd(Stream tmd)
|
||||||
|
{
|
||||||
|
this.fireDebug("Scanning TMD for Certificates...");
|
||||||
|
byte[] buffer = new byte[2];
|
||||||
|
tmd.Seek(478L, SeekOrigin.Begin);
|
||||||
|
tmd.Read(buffer, 0, 2);
|
||||||
|
int num = 484 + (int) Shared.Swap(BitConverter.ToUInt16(buffer, 0)) * 36;
|
||||||
|
for (int index = 0; index < 3; ++index)
|
||||||
|
{
|
||||||
|
this.fireDebug(" Scanning at Offset 0x{0}:", (object) num.ToString("x8"));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
tmd.Seek((long) num, SeekOrigin.Begin);
|
||||||
|
byte[] array = new byte[1024];
|
||||||
|
tmd.Read(array, 0, array.Length);
|
||||||
|
this.fireDebug(" Checking for Certificate CA...");
|
||||||
|
if (this.isCertCa(array) && !this.certsComplete[1])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CA detected...");
|
||||||
|
this.certCa = array;
|
||||||
|
this.certsComplete[1] = true;
|
||||||
|
num += 1024;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate CP...");
|
||||||
|
if (this.isCertCp(array) && !this.certsComplete[2])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate CP detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certCp = array;
|
||||||
|
this.certsComplete[2] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
this.fireDebug(" Checking for Certificate XS...");
|
||||||
|
if (this.isCertXs(array))
|
||||||
|
{
|
||||||
|
if (!this.certsComplete[0])
|
||||||
|
{
|
||||||
|
this.fireDebug(" Certificate XS detected...");
|
||||||
|
Array.Resize<byte>(ref array, 768);
|
||||||
|
this.certXs = array;
|
||||||
|
this.certsComplete[0] = true;
|
||||||
|
num += 768;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
}
|
||||||
|
num += 768;
|
||||||
|
}
|
||||||
|
this.fireDebug("Scanning TMD for Certificates Finished...");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isCertXs(byte[] part)
|
||||||
|
{
|
||||||
|
if (part.Length < 768)
|
||||||
|
return false;
|
||||||
|
if (part.Length > 768)
|
||||||
|
Array.Resize<byte>(ref part, 768);
|
||||||
|
return part[388] == (byte) 88 && part[389] == (byte) 83 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("09787045037121477824BC6A3E5E076156573F8A"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isCertCa(byte[] part)
|
||||||
|
{
|
||||||
|
if (part.Length < 1024)
|
||||||
|
return false;
|
||||||
|
if (part.Length > 1024)
|
||||||
|
Array.Resize<byte>(ref part, 1024);
|
||||||
|
return part[644] == (byte) 67 && part[645] == (byte) 65 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("5B7D3EE28706AD8DA2CBD5A6B75C15D0F9B6F318"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool isCertCp(byte[] part)
|
||||||
|
{
|
||||||
|
if (part.Length < 768)
|
||||||
|
return false;
|
||||||
|
if (part.Length > 768)
|
||||||
|
Array.Resize<byte>(ref part, 768);
|
||||||
|
return part[388] == (byte) 67 && part[389] == (byte) 80 && Shared.CompareByteArrays(this.sha.ComputeHash(part), Shared.HexStringToByteArray("6824D6DA4C25184F0D6DAF6EDB9C0FC57522A41C"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireDebug(string debugMessage, params object[] args)
|
||||||
|
{
|
||||||
|
EventHandler<MessageEventArgs> debug = this.Debug;
|
||||||
|
if (debug == null)
|
||||||
|
return;
|
||||||
|
debug(new object(), new MessageEventArgs(string.Format(debugMessage, args)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,279 +1,291 @@
|
||||||
// Decompiled with JetBrains decompiler
|
/* This file is part of libWiiSharp
|
||||||
// Type: libWiiSharp.ColorIndexConverter
|
* 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;
|
||||||
|
|
||||||
namespace libWiiSharp
|
namespace libWiiSharp
|
||||||
{
|
{
|
||||||
internal class ColorIndexConverter
|
internal class ColorIndexConverter
|
||||||
{
|
|
||||||
private uint[] rgbaPalette;
|
|
||||||
private byte[] tplPalette;
|
|
||||||
private uint[] rgbaData;
|
|
||||||
private byte[] tplData;
|
|
||||||
private TPL_TextureFormat tplFormat;
|
|
||||||
private TPL_PaletteFormat paletteFormat;
|
|
||||||
private int width;
|
|
||||||
private int height;
|
|
||||||
|
|
||||||
public byte[] Palette => this.tplPalette;
|
|
||||||
|
|
||||||
public byte[] Data => this.tplData;
|
|
||||||
|
|
||||||
public ColorIndexConverter(
|
|
||||||
uint[] rgbaData,
|
|
||||||
int width,
|
|
||||||
int height,
|
|
||||||
TPL_TextureFormat tplFormat,
|
|
||||||
TPL_PaletteFormat paletteFormat)
|
|
||||||
{
|
{
|
||||||
if (tplFormat != TPL_TextureFormat.CI4 && tplFormat != TPL_TextureFormat.CI8)
|
private uint[] rgbaPalette;
|
||||||
throw new Exception("Texture format must be either CI4 or CI8");
|
private byte[] tplPalette;
|
||||||
if (paletteFormat != TPL_PaletteFormat.IA8 && paletteFormat != TPL_PaletteFormat.RGB565 && paletteFormat != TPL_PaletteFormat.RGB5A3)
|
private uint[] rgbaData;
|
||||||
throw new Exception("Palette format must be either IA8, RGB565 or RGB5A3!");
|
private byte[] tplData;
|
||||||
this.rgbaData = rgbaData;
|
private TPL_TextureFormat tplFormat;
|
||||||
this.width = width;
|
private TPL_PaletteFormat paletteFormat;
|
||||||
this.height = height;
|
private int width;
|
||||||
this.tplFormat = tplFormat;
|
private int height;
|
||||||
this.paletteFormat = paletteFormat;
|
|
||||||
this.buildPalette();
|
|
||||||
if (tplFormat != TPL_TextureFormat.CI4)
|
|
||||||
{
|
|
||||||
if (tplFormat == TPL_TextureFormat.CI8)
|
|
||||||
this.toCI8();
|
|
||||||
else
|
|
||||||
this.toCI14X2();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
this.toCI4();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toCI4()
|
public byte[] Palette => this.tplPalette;
|
||||||
{
|
|
||||||
byte[] numArray = new byte[Shared.AddPadding(this.width, 8) * Shared.AddPadding(this.height, 8) / 2];
|
public byte[] Data => this.tplData;
|
||||||
int num = 0;
|
|
||||||
for (int index1 = 0; index1 < this.height; index1 += 8)
|
public ColorIndexConverter(
|
||||||
{
|
uint[] rgbaData,
|
||||||
for (int index2 = 0; index2 < this.width; index2 += 8)
|
int width,
|
||||||
|
int height,
|
||||||
|
TPL_TextureFormat tplFormat,
|
||||||
|
TPL_PaletteFormat paletteFormat)
|
||||||
{
|
{
|
||||||
for (int index3 = index1; index3 < index1 + 8; ++index3)
|
if (tplFormat != TPL_TextureFormat.CI4 && tplFormat != TPL_TextureFormat.CI8)
|
||||||
{
|
throw new Exception("Texture format must be either CI4 or CI8");
|
||||||
for (int index4 = index2; index4 < index2 + 8; index4 += 2)
|
if (paletteFormat != TPL_PaletteFormat.IA8 && paletteFormat != TPL_PaletteFormat.RGB565 && paletteFormat != TPL_PaletteFormat.RGB5A3)
|
||||||
|
throw new Exception("Palette format must be either IA8, RGB565 or RGB5A3!");
|
||||||
|
this.rgbaData = rgbaData;
|
||||||
|
this.width = width;
|
||||||
|
this.height = height;
|
||||||
|
this.tplFormat = tplFormat;
|
||||||
|
this.paletteFormat = paletteFormat;
|
||||||
|
this.buildPalette();
|
||||||
|
if (tplFormat != TPL_TextureFormat.CI4)
|
||||||
{
|
{
|
||||||
uint colorIndex1 = this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4]);
|
if (tplFormat == TPL_TextureFormat.CI8)
|
||||||
uint colorIndex2 = this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : (index3 * this.width + index4 + 1 < this.rgbaData.Length ? this.rgbaData[index3 * this.width + index4 + 1] : 0U));
|
this.toCI8();
|
||||||
numArray[num++] = (byte) ((uint) (byte) colorIndex1 << 4 | (uint) (byte) colorIndex2);
|
else
|
||||||
|
this.toCI14X2();
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
this.toCI4();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.tplData = numArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toCI8()
|
private void toCI4()
|
||||||
{
|
|
||||||
byte[] numArray = new byte[Shared.AddPadding(this.width, 8) * Shared.AddPadding(this.height, 4)];
|
|
||||||
int num1 = 0;
|
|
||||||
for (int index1 = 0; index1 < this.height; index1 += 4)
|
|
||||||
{
|
|
||||||
for (int index2 = 0; index2 < this.width; index2 += 8)
|
|
||||||
{
|
{
|
||||||
for (int index3 = index1; index3 < index1 + 4; ++index3)
|
byte[] numArray = new byte[Shared.AddPadding(this.width, 8) * Shared.AddPadding(this.height, 8) / 2];
|
||||||
{
|
int num = 0;
|
||||||
for (int index4 = index2; index4 < index2 + 8; ++index4)
|
for (int index1 = 0; index1 < this.height; index1 += 8)
|
||||||
{
|
{
|
||||||
uint num2 = index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4];
|
for (int index2 = 0; index2 < this.width; index2 += 8)
|
||||||
numArray[num1++] = (byte) this.getColorIndex(num2);
|
{
|
||||||
|
for (int index3 = index1; index3 < index1 + 8; ++index3)
|
||||||
|
{
|
||||||
|
for (int index4 = index2; index4 < index2 + 8; index4 += 2)
|
||||||
|
{
|
||||||
|
uint colorIndex1 = this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4]);
|
||||||
|
uint colorIndex2 = this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : (index3 * this.width + index4 + 1 < this.rgbaData.Length ? this.rgbaData[index3 * this.width + index4 + 1] : 0U));
|
||||||
|
numArray[num++] = (byte) ((uint) (byte) colorIndex1 << 4 | (uint) (byte) colorIndex2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
this.tplData = numArray;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.tplData = numArray;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void toCI14X2()
|
private void toCI8()
|
||||||
{
|
|
||||||
byte[] numArray1 = new byte[Shared.AddPadding(this.width, 4) * Shared.AddPadding(this.height, 4) * 2];
|
|
||||||
int num1 = 0;
|
|
||||||
for (int index1 = 0; index1 < this.height; index1 += 4)
|
|
||||||
{
|
|
||||||
for (int index2 = 0; index2 < this.width; index2 += 4)
|
|
||||||
{
|
{
|
||||||
for (int index3 = index1; index3 < index1 + 4; ++index3)
|
byte[] numArray = new byte[Shared.AddPadding(this.width, 8) * Shared.AddPadding(this.height, 4)];
|
||||||
{
|
int num1 = 0;
|
||||||
for (int index4 = index2; index4 < index2 + 4; ++index4)
|
for (int index1 = 0; index1 < this.height; index1 += 4)
|
||||||
{
|
{
|
||||||
byte[] bytes = BitConverter.GetBytes((ushort) this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4]));
|
for (int index2 = 0; index2 < this.width; index2 += 8)
|
||||||
byte[] numArray2 = numArray1;
|
{
|
||||||
int index5 = num1;
|
for (int index3 = index1; index3 < index1 + 4; ++index3)
|
||||||
int num2 = index5 + 1;
|
{
|
||||||
int num3 = (int) bytes[1];
|
for (int index4 = index2; index4 < index2 + 8; ++index4)
|
||||||
numArray2[index5] = (byte) num3;
|
{
|
||||||
byte[] numArray3 = numArray1;
|
uint num2 = index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4];
|
||||||
int index6 = num2;
|
numArray[num1++] = (byte) this.getColorIndex(num2);
|
||||||
num1 = index6 + 1;
|
}
|
||||||
int num4 = (int) bytes[0];
|
}
|
||||||
numArray3[index6] = (byte) num4;
|
}
|
||||||
}
|
}
|
||||||
}
|
this.tplData = numArray;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
this.tplData = numArray1;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void buildPalette()
|
private void toCI14X2()
|
||||||
{
|
|
||||||
int num1 = 256;
|
|
||||||
if (this.tplFormat == TPL_TextureFormat.CI4)
|
|
||||||
num1 = 16;
|
|
||||||
else if (this.tplFormat == TPL_TextureFormat.CI14X2)
|
|
||||||
num1 = 16384;
|
|
||||||
List<uint> uintList = new List<uint>();
|
|
||||||
List<ushort> ushortList = new List<ushort>();
|
|
||||||
uintList.Add(0U);
|
|
||||||
ushortList.Add((ushort) 0);
|
|
||||||
for (int index = 1; index < this.rgbaData.Length && uintList.Count != num1; ++index)
|
|
||||||
{
|
|
||||||
if ((long) (this.rgbaData[index] >> 24 & (uint) byte.MaxValue) >= (this.tplFormat == TPL_TextureFormat.CI14X2 ? 1L : 25L))
|
|
||||||
{
|
{
|
||||||
ushort num2 = Shared.Swap(this.convertToPaletteValue((int) this.rgbaData[index]));
|
byte[] numArray1 = new byte[Shared.AddPadding(this.width, 4) * Shared.AddPadding(this.height, 4) * 2];
|
||||||
if (!uintList.Contains(this.rgbaData[index]) && !ushortList.Contains(num2))
|
int num1 = 0;
|
||||||
{
|
for (int index1 = 0; index1 < this.height; index1 += 4)
|
||||||
uintList.Add(this.rgbaData[index]);
|
{
|
||||||
ushortList.Add(num2);
|
for (int index2 = 0; index2 < this.width; index2 += 4)
|
||||||
}
|
{
|
||||||
|
for (int index3 = index1; index3 < index1 + 4; ++index3)
|
||||||
|
{
|
||||||
|
for (int index4 = index2; index4 < index2 + 4; ++index4)
|
||||||
|
{
|
||||||
|
byte[] bytes = BitConverter.GetBytes((ushort) this.getColorIndex(index3 >= this.height || index4 >= this.width ? 0U : this.rgbaData[index3 * this.width + index4]));
|
||||||
|
byte[] numArray2 = numArray1;
|
||||||
|
int index5 = num1;
|
||||||
|
int num2 = index5 + 1;
|
||||||
|
int num3 = (int) bytes[1];
|
||||||
|
numArray2[index5] = (byte) num3;
|
||||||
|
byte[] numArray3 = numArray1;
|
||||||
|
int index6 = num2;
|
||||||
|
num1 = index6 + 1;
|
||||||
|
int num4 = (int) bytes[0];
|
||||||
|
numArray3[index6] = (byte) num4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.tplData = numArray1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
while (uintList.Count % 16 != 0)
|
|
||||||
{
|
|
||||||
uintList.Add(uint.MaxValue);
|
|
||||||
ushortList.Add(ushort.MaxValue);
|
|
||||||
}
|
|
||||||
this.tplPalette = Shared.UShortArrayToByteArray(ushortList.ToArray());
|
|
||||||
this.rgbaPalette = uintList.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
private ushort convertToPaletteValue(int rgba)
|
private void buildPalette()
|
||||||
{
|
|
||||||
int num1 = 0;
|
|
||||||
int num2;
|
|
||||||
if (this.paletteFormat == TPL_PaletteFormat.IA8)
|
|
||||||
{
|
|
||||||
int num3 = ((rgba & (int) byte.MaxValue) + (rgba >> 8 & (int) byte.MaxValue) + (rgba >> 16 & (int) byte.MaxValue)) / 3 & (int) byte.MaxValue;
|
|
||||||
num2 = (int) (ushort) ((rgba >> 24 & (int) byte.MaxValue) << 8 | num3);
|
|
||||||
}
|
|
||||||
else if (this.paletteFormat == TPL_PaletteFormat.RGB565)
|
|
||||||
{
|
|
||||||
num2 = (int) (ushort) ((rgba >> 16 & (int) byte.MaxValue) >> 3 << 11 | (rgba >> 8 & (int) byte.MaxValue) >> 2 << 5 | (rgba & (int) byte.MaxValue) >> 3);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
int num3 = rgba >> 16 & (int) byte.MaxValue;
|
|
||||||
int num4 = rgba >> 8 & (int) byte.MaxValue;
|
|
||||||
int num5 = rgba & (int) byte.MaxValue;
|
|
||||||
int num6 = rgba >> 24 & (int) byte.MaxValue;
|
|
||||||
if (num6 <= 218)
|
|
||||||
{
|
{
|
||||||
int num7 = num1 & -32769;
|
int num1 = 256;
|
||||||
int num8 = num3 * 15 / (int) byte.MaxValue & 15;
|
if (this.tplFormat == TPL_TextureFormat.CI4)
|
||||||
int num9 = num4 * 15 / (int) byte.MaxValue & 15;
|
num1 = 16;
|
||||||
int num10 = num5 * 15 / (int) byte.MaxValue & 15;
|
else if (this.tplFormat == TPL_TextureFormat.CI14X2)
|
||||||
int num11 = num6 * 7 / (int) byte.MaxValue & 7;
|
num1 = 16384;
|
||||||
num2 = num7 | num11 << 12 | num10 | num9 << 4 | num8 << 8;
|
List<uint> uintList = new List<uint>();
|
||||||
|
List<ushort> ushortList = new List<ushort>();
|
||||||
|
uintList.Add(0U);
|
||||||
|
ushortList.Add((ushort) 0);
|
||||||
|
for (int index = 1; index < this.rgbaData.Length && uintList.Count != num1; ++index)
|
||||||
|
{
|
||||||
|
if ((long) (this.rgbaData[index] >> 24 & (uint) byte.MaxValue) >= (this.tplFormat == TPL_TextureFormat.CI14X2 ? 1L : 25L))
|
||||||
|
{
|
||||||
|
ushort num2 = Shared.Swap(this.convertToPaletteValue((int) this.rgbaData[index]));
|
||||||
|
if (!uintList.Contains(this.rgbaData[index]) && !ushortList.Contains(num2))
|
||||||
|
{
|
||||||
|
uintList.Add(this.rgbaData[index]);
|
||||||
|
ushortList.Add(num2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (uintList.Count % 16 != 0)
|
||||||
|
{
|
||||||
|
uintList.Add(uint.MaxValue);
|
||||||
|
ushortList.Add(ushort.MaxValue);
|
||||||
|
}
|
||||||
|
this.tplPalette = Shared.UShortArrayToByteArray(ushortList.ToArray());
|
||||||
|
this.rgbaPalette = uintList.ToArray();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
int num7 = num1 | 32768;
|
|
||||||
int num8 = num3 * 31 / (int) byte.MaxValue & 31;
|
|
||||||
int num9 = num4 * 31 / (int) byte.MaxValue & 31;
|
|
||||||
int num10 = num5 * 31 / (int) byte.MaxValue & 31;
|
|
||||||
num2 = num7 | num10 | num9 << 5 | num8 << 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return (ushort) num2;
|
|
||||||
}
|
|
||||||
|
|
||||||
private uint getColorIndex(uint value)
|
private ushort convertToPaletteValue(int rgba)
|
||||||
{
|
|
||||||
uint num1 = (uint) int.MaxValue;
|
|
||||||
uint num2 = 0;
|
|
||||||
if ((long) (value >> 24 & (uint) byte.MaxValue) < (this.tplFormat == TPL_TextureFormat.CI14X2 ? 1L : 25L))
|
|
||||||
return 0;
|
|
||||||
ushort paletteValue1 = this.convertToPaletteValue((int) value);
|
|
||||||
for (int index = 0; index < this.rgbaPalette.Length; ++index)
|
|
||||||
{
|
|
||||||
ushort paletteValue2 = this.convertToPaletteValue((int) this.rgbaPalette[index]);
|
|
||||||
if ((int) paletteValue1 == (int) paletteValue2)
|
|
||||||
return (uint) index;
|
|
||||||
uint distance = this.getDistance(paletteValue1, paletteValue2);
|
|
||||||
if (distance < num1)
|
|
||||||
{
|
{
|
||||||
num1 = distance;
|
int num1 = 0;
|
||||||
num2 = (uint) index;
|
int num2;
|
||||||
|
if (this.paletteFormat == TPL_PaletteFormat.IA8)
|
||||||
|
{
|
||||||
|
int num3 = ((rgba & (int) byte.MaxValue) + (rgba >> 8 & (int) byte.MaxValue) + (rgba >> 16 & (int) byte.MaxValue)) / 3 & (int) byte.MaxValue;
|
||||||
|
num2 = (int) (ushort) ((rgba >> 24 & (int) byte.MaxValue) << 8 | num3);
|
||||||
|
}
|
||||||
|
else if (this.paletteFormat == TPL_PaletteFormat.RGB565)
|
||||||
|
{
|
||||||
|
num2 = (int) (ushort) ((rgba >> 16 & (int) byte.MaxValue) >> 3 << 11 | (rgba >> 8 & (int) byte.MaxValue) >> 2 << 5 | (rgba & (int) byte.MaxValue) >> 3);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num3 = rgba >> 16 & (int) byte.MaxValue;
|
||||||
|
int num4 = rgba >> 8 & (int) byte.MaxValue;
|
||||||
|
int num5 = rgba & (int) byte.MaxValue;
|
||||||
|
int num6 = rgba >> 24 & (int) byte.MaxValue;
|
||||||
|
if (num6 <= 218)
|
||||||
|
{
|
||||||
|
int num7 = num1 & -32769;
|
||||||
|
int num8 = num3 * 15 / (int) byte.MaxValue & 15;
|
||||||
|
int num9 = num4 * 15 / (int) byte.MaxValue & 15;
|
||||||
|
int num10 = num5 * 15 / (int) byte.MaxValue & 15;
|
||||||
|
int num11 = num6 * 7 / (int) byte.MaxValue & 7;
|
||||||
|
num2 = num7 | num11 << 12 | num10 | num9 << 4 | num8 << 8;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int num7 = num1 | 32768;
|
||||||
|
int num8 = num3 * 31 / (int) byte.MaxValue & 31;
|
||||||
|
int num9 = num4 * 31 / (int) byte.MaxValue & 31;
|
||||||
|
int num10 = num5 * 31 / (int) byte.MaxValue & 31;
|
||||||
|
num2 = num7 | num10 | num9 << 5 | num8 << 10;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (ushort) num2;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
private uint getColorIndex(uint value)
|
||||||
|
{
|
||||||
|
uint num1 = (uint) int.MaxValue;
|
||||||
|
uint num2 = 0;
|
||||||
|
if ((long) (value >> 24 & (uint) byte.MaxValue) < (this.tplFormat == TPL_TextureFormat.CI14X2 ? 1L : 25L))
|
||||||
|
return 0;
|
||||||
|
ushort paletteValue1 = this.convertToPaletteValue((int) value);
|
||||||
|
for (int index = 0; index < this.rgbaPalette.Length; ++index)
|
||||||
|
{
|
||||||
|
ushort paletteValue2 = this.convertToPaletteValue((int) this.rgbaPalette[index]);
|
||||||
|
if ((int) paletteValue1 == (int) paletteValue2)
|
||||||
|
return (uint) index;
|
||||||
|
uint distance = this.getDistance(paletteValue1, paletteValue2);
|
||||||
|
if (distance < num1)
|
||||||
|
{
|
||||||
|
num1 = distance;
|
||||||
|
num2 = (uint) index;
|
||||||
|
}
|
||||||
|
}
|
||||||
return num2;
|
return num2;
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint getDistance(ushort color, ushort paletteColor)
|
private uint getDistance(ushort color, ushort paletteColor)
|
||||||
{
|
{
|
||||||
int rgbaValue1 = (int) this.convertToRgbaValue(color);
|
int rgbaValue1 = (int) this.convertToRgbaValue(color);
|
||||||
uint rgbaValue2 = this.convertToRgbaValue(paletteColor);
|
uint rgbaValue2 = this.convertToRgbaValue(paletteColor);
|
||||||
uint val1_1 = (uint) rgbaValue1 >> 24 & (uint) byte.MaxValue;
|
uint val1_1 = (uint) rgbaValue1 >> 24 & (uint) byte.MaxValue;
|
||||||
uint val1_2 = (uint) rgbaValue1 >> 16 & (uint) byte.MaxValue;
|
uint val1_2 = (uint) rgbaValue1 >> 16 & (uint) byte.MaxValue;
|
||||||
uint val1_3 = (uint) rgbaValue1 >> 8 & (uint) byte.MaxValue;
|
uint val1_3 = (uint) rgbaValue1 >> 8 & (uint) byte.MaxValue;
|
||||||
uint val1_4 = (uint) (rgbaValue1 & (int) byte.MaxValue);
|
uint val1_4 = (uint) (rgbaValue1 & (int) byte.MaxValue);
|
||||||
uint val2_1 = rgbaValue2 >> 24 & (uint) byte.MaxValue;
|
uint val2_1 = rgbaValue2 >> 24 & (uint) byte.MaxValue;
|
||||||
uint val2_2 = rgbaValue2 >> 16 & (uint) byte.MaxValue;
|
uint val2_2 = rgbaValue2 >> 16 & (uint) byte.MaxValue;
|
||||||
uint val2_3 = rgbaValue2 >> 8 & (uint) byte.MaxValue;
|
uint val2_3 = rgbaValue2 >> 8 & (uint) byte.MaxValue;
|
||||||
uint val2_4 = rgbaValue2 & (uint) byte.MaxValue;
|
uint val2_4 = rgbaValue2 & (uint) byte.MaxValue;
|
||||||
int num1 = (int) Math.Max(val1_1, val2_1) - (int) Math.Min(val1_1, val2_1);
|
int num1 = (int) Math.Max(val1_1, val2_1) - (int) Math.Min(val1_1, val2_1);
|
||||||
uint num2 = Math.Max(val1_2, val2_2) - Math.Min(val1_2, val2_2);
|
uint num2 = Math.Max(val1_2, val2_2) - Math.Min(val1_2, val2_2);
|
||||||
uint num3 = Math.Max(val1_3, val2_3) - Math.Min(val1_3, val2_3);
|
uint num3 = Math.Max(val1_3, val2_3) - Math.Min(val1_3, val2_3);
|
||||||
uint num4 = Math.Max(val1_4, val2_4) - Math.Min(val1_4, val2_4);
|
uint num4 = Math.Max(val1_4, val2_4) - Math.Min(val1_4, val2_4);
|
||||||
int num5 = (int) num2;
|
int num5 = (int) num2;
|
||||||
return (uint) (num1 + num5) + num3 + num4;
|
return (uint) (num1 + num5) + num3 + num4;
|
||||||
}
|
}
|
||||||
|
|
||||||
private uint convertToRgbaValue(ushort pixel)
|
private uint convertToRgbaValue(ushort pixel)
|
||||||
{
|
{
|
||||||
if (this.paletteFormat == TPL_PaletteFormat.IA8)
|
if (this.paletteFormat == TPL_PaletteFormat.IA8)
|
||||||
{
|
{
|
||||||
int num1 = (int) pixel >> 8;
|
int num1 = (int) pixel >> 8;
|
||||||
int num2 = (int) pixel & (int) byte.MaxValue;
|
int num2 = (int) pixel & (int) byte.MaxValue;
|
||||||
return (uint) (num1 | num1 << 8 | num1 << 16 | num2 << 24);
|
return (uint) (num1 | num1 << 8 | num1 << 16 | num2 << 24);
|
||||||
}
|
}
|
||||||
if (this.paletteFormat == TPL_PaletteFormat.RGB565)
|
if (this.paletteFormat == TPL_PaletteFormat.RGB565)
|
||||||
{
|
{
|
||||||
int num1 = ((int) pixel >> 11 & 31) << 3 & (int) byte.MaxValue;
|
int num1 = ((int) pixel >> 11 & 31) << 3 & (int) byte.MaxValue;
|
||||||
int num2 = ((int) pixel >> 5 & 63) << 2 & (int) byte.MaxValue;
|
int num2 = ((int) pixel >> 5 & 63) << 2 & (int) byte.MaxValue;
|
||||||
int num3 = ((int) pixel & 31) << 3 & (int) byte.MaxValue;
|
int num3 = ((int) pixel & 31) << 3 & (int) byte.MaxValue;
|
||||||
int maxValue = (int) byte.MaxValue;
|
int maxValue = (int) byte.MaxValue;
|
||||||
return (uint) (num3 | num2 << 8 | num1 << 16 | maxValue << 24);
|
return (uint) (num3 | num2 << 8 | num1 << 16 | maxValue << 24);
|
||||||
}
|
}
|
||||||
int num4;
|
int num4;
|
||||||
int num5;
|
int num5;
|
||||||
int num6;
|
int num6;
|
||||||
int num7;
|
int num7;
|
||||||
if (((int) pixel & 32768) != 0)
|
if (((int) pixel & 32768) != 0)
|
||||||
{
|
{
|
||||||
num4 = ((int) pixel >> 10 & 31) * (int) byte.MaxValue / 31;
|
num4 = ((int) pixel >> 10 & 31) * (int) byte.MaxValue / 31;
|
||||||
num5 = ((int) pixel >> 5 & 31) * (int) byte.MaxValue / 31;
|
num5 = ((int) pixel >> 5 & 31) * (int) byte.MaxValue / 31;
|
||||||
num6 = ((int) pixel & 31) * (int) byte.MaxValue / 31;
|
num6 = ((int) pixel & 31) * (int) byte.MaxValue / 31;
|
||||||
num7 = (int) byte.MaxValue;
|
num7 = (int) byte.MaxValue;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
num7 = ((int) pixel >> 12 & 7) * (int) byte.MaxValue / 7;
|
num7 = ((int) pixel >> 12 & 7) * (int) byte.MaxValue / 7;
|
||||||
num4 = ((int) pixel >> 8 & 15) * (int) byte.MaxValue / 15;
|
num4 = ((int) pixel >> 8 & 15) * (int) byte.MaxValue / 15;
|
||||||
num5 = ((int) pixel >> 4 & 15) * (int) byte.MaxValue / 15;
|
num5 = ((int) pixel >> 4 & 15) * (int) byte.MaxValue / 15;
|
||||||
num6 = ((int) pixel & 15) * (int) byte.MaxValue / 15;
|
num6 = ((int) pixel & 15) * (int) byte.MaxValue / 15;
|
||||||
}
|
}
|
||||||
return (uint) (num6 | num5 << 8 | num4 << 16 | num7 << 24);
|
return (uint) (num6 | num5 << 8 | num4 << 16 | num7 << 24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
<RegisterForComInterop>true</RegisterForComInterop>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
@ -34,6 +35,7 @@
|
||||||
<ErrorReport>prompt</ErrorReport>
|
<ErrorReport>prompt</ErrorReport>
|
||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
<Prefer32Bit>false</Prefer32Bit>
|
<Prefer32Bit>false</Prefer32Bit>
|
||||||
|
<RegisterForComInterop>false</RegisterForComInterop>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SignAssembly>false</SignAssembly>
|
<SignAssembly>false</SignAssembly>
|
||||||
|
@ -93,5 +95,8 @@
|
||||||
<Compile Include="zlibWrapper.cs" />
|
<Compile Include="zlibWrapper.cs" />
|
||||||
<Compile Include="AssemblyInfo.cs" />
|
<Compile Include="AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include=".gitignore" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
Loading…
Reference in a new issue