commit 47b787b9e8d853769c02081de359cb0511175e75 Author: mzolob@gmail.com Date: Tue Sep 27 03:19:01 2011 +0000 Initial Release, yay! ^_^ diff --git a/Sharpii.sln b/Sharpii.sln new file mode 100644 index 0000000..1fb0189 --- /dev/null +++ b/Sharpii.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C# Express 2010 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpii", "Sharpii\Sharpii.csproj", "{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Debug|x86.ActiveCfg = Debug|x86 + {AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Debug|x86.Build.0 = Debug|x86 + {AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|x86.ActiveCfg = Release|x86 + {AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Sharpii/BNS.cs b/Sharpii/BNS.cs new file mode 100644 index 0000000..829f83f --- /dev/null +++ b/Sharpii/BNS.cs @@ -0,0 +1,203 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class BNS_Stuff + { + public static void BNS(string[] args) + { + if (args.Length < 4) + { + Wav2BNS_help(); + return; + } + + //********************* To BNS ********************* + if (args[1] == "-to") + { + To(args); + return; + } + + if (args[1] == "-from") + { + From(args); + return; + } + + return; + } + + private static void From(string[] args) + { + string input = args[2]; + string output = args[3]; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //Run main part, and check for exceptions + try + { + //Now convert it + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + Wave WavFile = libWiiSharp.BNS.BnsToWave(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 2) + System.Console.Write("Saving wav..."); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAV") + output = output + ".wav"; + + WavFile.Save(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void To(string[] args) + { + string input = args[2]; + string output = args[3]; + bool loop = false; + bool mono = false; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-L": + loop = true; + break; + case "-LOOP": + loop = true; + break; + case "-M": + mono = true; + break; + case "-MONO": + mono = true; + break; + } + } + + //Run main part, and check for exceptions + try + { + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + BNS WavFile = new BNS(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (loop == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Applying loop"); + WavFile.SetLoop(1); + } + if (mono == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Converting to mono"); + WavFile.StereoToMono = true; + } + + if (Quiet.quiet > 2) + System.Console.Write("Saving BNS..."); + + WavFile.Convert(); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".BNS") + output = output + ".bns"; + + WavFile.Save(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + public static void Wav2BNS_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - BNS - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii BNS [-to | -from] input.wav output.bns [-l/-loop] [-m/-mono]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -to Convert wav to bns"); + System.Console.WriteLine(" -from Create wav from bns"); + System.Console.WriteLine(" input.wav The input wave sound file"); + System.Console.WriteLine(" output.bns The output BNS sound file"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for converting to BNS:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -l | -loop Creates a looping BNS"); + System.Console.WriteLine(" -m | -mono Convert stereo sound to mono BNS"); + } + } +} diff --git a/Sharpii/HBC.cs b/Sharpii/HBC.cs new file mode 100644 index 0000000..a94eadf --- /dev/null +++ b/Sharpii/HBC.cs @@ -0,0 +1,134 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class HBC_Stuff + { + public static void SendDol(string[] args) + { + if (args.Length < 3) + { + SendDol_help(); + return; + } + string input = args[1]; + string ip = ""; + string protocol = "JODI"; + bool compress = true; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //Get parameters + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-IP": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No ip set"); + return; + } + ip = args[i + 1]; + break; + case "-NOCOMP": + compress = false; + break; + case "-OLD": + protocol = "HAXX"; + break; + } + } + + //Run main part, and check for exceptions + try + { + libWiiSharp.Protocol proto = Protocol.JODI; + + if (Quiet.quiet > 2 && protocol == "HAXX") + System.Console.WriteLine("Using old protocol"); + + if (protocol == "HAXX") + proto = Protocol.HAXX; + + if (Quiet.quiet > 2) + System.Console.Write("Loading File..."); + + HbcTransmitter file = new HbcTransmitter(proto, ip); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + + if (Quiet.quiet > 2 && compress == true) + System.Console.Write("Compressing File..."); + + file.Compress = compress; + + if (Quiet.quiet > 2 && compress == true) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.Write("Sending file..."); + + file.TransmitFile(input); + + if (Quiet.quiet > 1) + System.Console.Write("Done!\n"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + + return; + + } + + public static void SendDol_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - SendDol - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii.exe SendDol file -ip ip_adress [-old] [-nocomp]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" file The dol file to send"); + System.Console.WriteLine(" -ip ip_adress The IP address of your wii"); + System.Console.WriteLine(" -old Use for the old (1.0.4 and below) HBC"); + System.Console.WriteLine(" -nocomp Disable compression"); + } + } +} \ No newline at end of file diff --git a/Sharpii/IOS.cs b/Sharpii/IOS.cs new file mode 100644 index 0000000..eb295f6 --- /dev/null +++ b/Sharpii/IOS.cs @@ -0,0 +1,226 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class IOS_Stuff + { + public static void IOS(string[] args) + { + if (args.Length < 3) + { + IOS_help(); + return; + } + string input = args[1]; + string output = ""; + bool fs = false; + bool es = false; + bool np = false; + int slot = -1; + int version = -1; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //Get parameters + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-FS": + fs = true; + break; + case "-ES": + es = true; + break; + case "-NP": + np = true; + break; + case "-SLOT": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No slot set"); + return; + } + if (!int.TryParse(args[i + 1], out slot)) + { + Console.WriteLine("Invalid slot {0}...", args[i + 1]); + return; + } + if (slot < 3 || slot > 255) + { + Console.WriteLine("Invalid slot {0}...", slot); + return; + } + break; + case "-V": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No version set"); + return; + } + if (!int.TryParse(args[i + 1], out version)) + { + Console.WriteLine("Invalid version {0}...", args[i + 1]); + return; + } + if (version < 0 || version > 65535) + { + Console.WriteLine("Invalid version {0}...", version); + return; + } + break; + case "-O": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No output set"); + return; + } + output = args[i + 1]; + break; + } + } + + //Main part (most of it was borrowed from PatchIOS) + try + { + WAD ios = new WAD(); + ios.KeepOriginalFooter = true; + + if (Quiet.quiet > 2) + System.Console.Write("Loading File..."); + + ios.LoadFile(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + //Check if WAD is an IOS + if ((ios.TitleID >> 32) != 1 || (ios.TitleID & 0xffffffff) > 255 || (ios.TitleID & 0xffffffff) < 3) + { + Console.WriteLine("Only IOS WADs can be patched..."); + return; + } + + IosPatcher patcher = new IosPatcher(); + + patcher.LoadIOS(ref ios); + + //apply patches + if (fs == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Applying Fakesigning patch"); + patcher.PatchFakeSigning(); + } + + if (es == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Applying ES_Identify patch"); + patcher.PatchEsIdentify(); + } + + if (np == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Applying NAND permissions patch"); + patcher.PatchNandPermissions(); + } + + if (slot > -1 || version > -1) + ios.FakeSign = true; + + if (slot > -1) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing IOS slot to: {0}", slot); + ios.TitleID = (ulong)((1UL << 32) | (uint)slot); + } + + if (version > -1) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing title version to: {0}", version); + ios.TitleVersion = (ushort)version; + } + + //check if output was set + if (output != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Saving to file: {0}", output); + ios.Save(output); + } + else + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Saving file"); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAD") + output = output + ".wad"; + + ios.Save(input); + } + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + + return; + + } + + public static void IOS_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - IOS - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(" Code based off PatchIOS by leathl"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii.exe IOS input [-o output] [-fs] [-es] [-np] [-s slot] [-v version]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" input The input file/folder"); + System.Console.WriteLine(" -o output The output file/folder"); + System.Console.WriteLine(" -fs Patch Fakesigning"); + System.Console.WriteLine(" -es Patch ES_Identify"); + System.Console.WriteLine(" -np Patch NAND Permissions"); + System.Console.WriteLine(" -slot # Change IOS slot to #"); + System.Console.WriteLine(" -v # Change IOS version to #"); + } + } +} \ No newline at end of file diff --git a/Sharpii/Program.cs b/Sharpii/Program.cs new file mode 100644 index 0000000..0dd2ab3 --- /dev/null +++ b/Sharpii/Program.cs @@ -0,0 +1,146 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + class MainApp + { + static void Main(string[] args) + { + if (args.Length < 1) + { + help(); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-QUIET": + Quiet.quiet = 1; + break; + case "-Q": + Quiet.quiet = 1; + break; + case "-LOTS": + Quiet.quiet = 3; + break; + } + } + + string Function = args[0]; + + if (Function.ToUpper() == "-H" || Function.ToUpper() == "-HELP" || Function.ToUpper() == "H" || Function.ToUpper() == "HELP") + { + help(); + Environment.Exit(0); + } + + if (Function.ToUpper() == "BNS") + { + BNS_Stuff.BNS(args); + Environment.Exit(0); + } + + if (Function.ToUpper() == "WAD") + { + WAD_Stuff.WAD(args); + Environment.Exit(0); + } + + if (Function.ToUpper() == "TPL") + { + TPL_Stuff.TPL(args); + Environment.Exit(0); + } + + if (Function.ToUpper() == "U8") + { + U8_Stuff.U8(args); + Environment.Exit(0); + } + + if (Function.ToUpper() == "IOS") + { + IOS_Stuff.IOS(args); + Environment.Exit(0); + } + + if (Function.ToUpper() == "SENDDOL" || Function.ToUpper() == "SENDOL") + { + HBC_Stuff.SendDol(args); + Environment.Exit(0); + } + + + + //If tuser gets here, they entered something wrong + System.Console.WriteLine("ERROR: The argument {0} is invalid", args[0]); + + Environment.Exit(0); + } + + private static void help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii [function] [parameters] [-quiet | -q | -lots]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Functions:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" BNS Convert a wav to bns, or vice versa"); + System.Console.WriteLine(" WAD Pack/Unpack/Edit a wad file"); + System.Console.WriteLine(" TPL Convert a image to a tpl, or vice versa"); + System.Console.WriteLine(" U8 Pack/Unpack a U8 archive"); + System.Console.WriteLine(" IOS Apply various patches to an IOS"); + System.Console.WriteLine(" SendDol Send a dol to the HBC over wifi"); + System.Console.WriteLine(""); + System.Console.WriteLine(" NOTE: Too see more detailed descriptions of any of the above,"); + System.Console.WriteLine(" use 'Sharpii [function] -h'"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Global Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -quiet | -q Try not to display any output"); + System.Console.WriteLine(" -lots Display lots of output"); + System.Console.WriteLine(""); + + + } + + } + } + public class Quiet { + //1 = little + //2 = normal + //3 = lots + public static int quiet = 2; + } + public class Version + { + public static string version = "1.0"; + } \ No newline at end of file diff --git a/Sharpii/Properties/AssemblyInfo.cs b/Sharpii/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..7bfb214 --- /dev/null +++ b/Sharpii/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Sharpii")] +[assembly: AssemblyDescription("A command line app for libWiiSharp.dll")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Sharpii")] +[assembly: AssemblyCopyright("2011 Person66")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("88c17956-a329-4c36-8919-97334e6b6e4d")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Sharpii/Sharpii.csproj b/Sharpii/Sharpii.csproj new file mode 100644 index 0000000..b9e9382 --- /dev/null +++ b/Sharpii/Sharpii.csproj @@ -0,0 +1,100 @@ + + + + Debug + x86 + 8.0.30703 + 2.0 + {AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827} + Exe + Properties + Sharpii + Sharpii + v2.0 + + + 512 + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + x86 + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + true + + + x86 + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + true + + + + .\libWiiSharp.dll + + + + + + + + + + + + + + + + + + + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + true + + + False + Windows Installer 3.1 + true + + + + + \ No newline at end of file diff --git a/Sharpii/Sharpii.csproj.user b/Sharpii/Sharpii.csproj.user new file mode 100644 index 0000000..f3f09e3 --- /dev/null +++ b/Sharpii/Sharpii.csproj.user @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + publish\ + + + + + + en-US + false + + \ No newline at end of file diff --git a/Sharpii/TPL.cs b/Sharpii/TPL.cs new file mode 100644 index 0000000..22bdc0d --- /dev/null +++ b/Sharpii/TPL.cs @@ -0,0 +1,236 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class TPL_Stuff + { + public static void TPL(string[] args) + { + if (args.Length < 4) + { + TPL_help(); + return; + } + + //********************* To TPL ********************* + if (args[1] == "-to") + { + To(args); + return; + } + + //********************* From TPL ********************* + if (args[1] == "-from") + { + From(args); + return; + } + + //If tuser gets here, they entered something wrong + System.Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); + return; + + } + + private static void From(string[] args) + { + string input = args[2]; + string output = args[3]; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //Run main part, and check for exceptions + try + { + //Load tpl + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + TPL tplfile = libWiiSharp.TPL.Load(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + //save image + if (Quiet.quiet > 2) + System.Console.Write("Extracting texture..."); + + tplfile.ExtractTexture(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void To(string[] args) + { + //Setting up variables + string input = args[2]; + string output = args[3]; + string tplFormat = "RGB565"; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //Check for arguments + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-FORMAT": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No format set"); + return; + } + tplFormat = args[i + 1]; + break; + case "-F": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No format set"); + return; + } + tplFormat = args[i + 1]; + break; + } + } + + //Check if valid format was entered + if (tplFormat != "I4" & tplFormat != "I8" & tplFormat != "IA4" & tplFormat != "IA8" & tplFormat != "RGB565" & tplFormat != "RGB5A3" & tplFormat != "RGBA8") + { + System.Console.WriteLine("ERROR: Unknown format type: {0}", tplFormat); + return; + } + + + //Run main part, and check for exceptions + try + { + //Set format + TPL_TextureFormat format = TPL_TextureFormat.RGB565; + if (tplFormat == "I4") + format = TPL_TextureFormat.I4; + if (tplFormat == "I8") + format = TPL_TextureFormat.I8; + if (tplFormat == "IA4") + format = TPL_TextureFormat.IA4; + if (tplFormat == "IA8") + format = TPL_TextureFormat.IA8; + if (tplFormat == "RGB565") + format = TPL_TextureFormat.RGB565; + if (tplFormat == "RGB5A3") + format = TPL_TextureFormat.RGB5A3; + if (tplFormat == "RGBA8") + format = TPL_TextureFormat.RGBA8; + + if (Quiet.quiet > 2) + System.Console.WriteLine("Format set to: {0}", tplFormat); + + //Make tpl + if (Quiet.quiet > 2) + System.Console.Write("Creating tpl file..."); + + TPL tplfile = libWiiSharp.TPL.FromImage(input, format); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + //save + if (Quiet.quiet > 2) + System.Console.Write("Saving tpl file..."); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".TPL") + output = output + ".tpl"; + + tplfile.Save(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + public static void TPL_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - TPL - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii.exe TPL [-to | -from] input output [arguments]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -to Convert image to tpl"); + System.Console.WriteLine(" -from Create image from tpl"); + System.Console.WriteLine(" input The input file/folder"); + System.Console.WriteLine(" output The output file/folder"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for Converting to TPL:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -format | -f The format of the tpl. Possible values are:"); + System.Console.WriteLine(" RGBA8 (High Quality with Alpha)"); + System.Console.WriteLine(" RGB565 (Medium Quality without Alpha)"); + System.Console.WriteLine(" RGB5A3 (Low Quality with Alpha)"); + System.Console.WriteLine(" IA8 (High quality B/W with Alpha)"); + System.Console.WriteLine(" IA4 (Low Quality B/W with Alpha)"); + System.Console.WriteLine(" I8 (High Quality B/W without Alpha)"); + System.Console.WriteLine(" I4 (Low Quality B/W without Alpha)"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Notes:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" If no format is specified when converting to TPL, RGB565 is used."); + System.Console.WriteLine(" When converting to an image, the image format is chosen based on the extension"); + } + } +} \ No newline at end of file diff --git a/Sharpii/U8.cs b/Sharpii/U8.cs new file mode 100644 index 0000000..ec53229 --- /dev/null +++ b/Sharpii/U8.cs @@ -0,0 +1,227 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class U8_Stuff + { + public static void U8(string[] args) + { + if (args.Length < 4) + { + U8_help(); + return; + } + + //********************* Pack ********************* + if (args[1] == "-p") + { + Pack(args); + return; + } + + //********************* Unpack ********************* + if (args[1] == "-u") + { + Unpack(args); + return; + } + + //If tuser gets here, they entered something wrong + System.Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); + return; + + } + + private static void Unpack(string[] args) + { + string input = args[2]; + string output = args[3]; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + //Check if file is U8 + if (libWiiSharp.U8.IsU8(input) != true) + { + System.Console.WriteLine("ERROR: File {0} is not a U8 archive", input); + return; + } + + //Run main part, and check for exceptions + try + { + //Load U8 + U8 U8file = new U8(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + U8file.LoadFile(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 2) + System.Console.Write("Extracting file..."); + + U8file.Extract(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void Pack(string[] args) + { + //Setting up variables + string input = args[2]; + string output = args[3]; + bool lz77 = false; + bool imd5 = false; + string imet = ""; + + //Check if folder exists + if (Directory.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open Folder: {0}", input); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-LZ77": + lz77 = true; + break; + case "-IMD5": + imd5 = true; + break; + case "-IMET": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No title set"); + return; + } + imet = args[i + 1]; + break; + } + } + + if (imd5 == true && imet != "") + { + System.Console.WriteLine("ERROR: Cannot use IMET and IMD5 at the same time."); + return; + } + + //Run main part, and check for exceptions + try + { + U8 U8folder = new U8(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading folder..."); + + U8folder.CreateFromDirectory(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (imd5 == true) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Adding IMD5 Header"); + U8folder.AddHeaderImd5(); + } + + if (imet != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Adding IMET header with title: {0}", imet); + U8folder.AddHeaderImet(false, imet); + } + + if (lz77 == true) + { + //Yeah, I know this isnt where it actually compresses it + if (Quiet.quiet > 2) + System.Console.WriteLine("Compressing U8 archive"); + U8folder.Lz77Compress = true; + } + + if (Quiet.quiet > 2) + System.Console.WriteLine("Saving file"); + + U8folder.Save(output); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + public static void U8_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - U8 - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii.exe U8 [-p | -u] input output [arguments]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" input The input file/folder"); + System.Console.WriteLine(" output The output file/folder"); + System.Console.WriteLine(" -p Pack"); + System.Console.WriteLine(" -u Unpack"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for Packing:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -imet [title] Pack with an IMET header (for 00000000.app)"); + System.Console.WriteLine(" You MUST enter a channel title"); + System.Console.WriteLine(" -imd5 Pack with an IMD5 header (for Banner/Icon.bin)"); + System.Console.WriteLine(" -lz77 Compress with lz77"); + } + } +} \ No newline at end of file diff --git a/Sharpii/WAD.cs b/Sharpii/WAD.cs new file mode 100644 index 0000000..64cad66 --- /dev/null +++ b/Sharpii/WAD.cs @@ -0,0 +1,595 @@ +/* This file is part of Sharpii. + * Copyright (C) 2011 Person66 + * + * Sharpii 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. + * + * Sharpii 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 Sharpii. If not, see . + */ + +using System; +using System.IO; +using libWiiSharp; + +namespace Sharpii +{ + partial class WAD_Stuff + { + public static void WAD(string[] args) + { + if (args.Length < 3) + { + WAD_help(); + return; + } + + //********************* PACK ********************* + if (args[1] == "-p") + { + Pack(args); + return; + } + + //********************* UNPACK ********************* + if (args[1] == "-u") + { + Unpack(args); + return; + } + + //********************* EDIT ********************* + if (args[1] == "-e") + { + Edit(args); + return; + } + + //********************* INFO ********************* + if (args[1] == "-i") + { + Info(args); + return; + } + + //If tuser gets here, they entered something wrong + System.Console.WriteLine("ERROR: The argument {0} is invalid", args[1]); + + return; + } + + private static void Info(string[] args) + { + string input = args[2]; + string output = ""; + bool titles = false; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-O": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No output set"); + return; + } + output = args[i + 1]; + break; + case "-OUTPUT": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No output set"); + return; + } + output = args[i + 1]; + break; + case "-TITLES": + titles = true; + break; + } + } + + try + { + WAD wad = new WAD(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + wad.LoadFile(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1 && output == "") + { + System.Console.WriteLine("WAD Info:"); + System.Console.WriteLine(""); + if (titles == false) + System.Console.WriteLine("Title: {0}", wad.ChannelTitles[1]); + else + { + System.Console.WriteLine("Titles:\n"); + System.Console.WriteLine(" Japanese: {0}", wad.ChannelTitles[0]); + System.Console.WriteLine(" English: {0}", wad.ChannelTitles[1]); + System.Console.WriteLine(" German: {0}", wad.ChannelTitles[2]); + System.Console.WriteLine(" French: {0}", wad.ChannelTitles[3]); + System.Console.WriteLine(" Spanish: {0}", wad.ChannelTitles[4]); + System.Console.WriteLine(" Italian: {0}", wad.ChannelTitles[5]); + System.Console.WriteLine(" Dutch: {0}", wad.ChannelTitles[6]); + System.Console.WriteLine(" Korean: {0}\n", wad.ChannelTitles[7]); + } + System.Console.WriteLine("Title ID: {0}", wad.UpperTitleID); + System.Console.WriteLine("IOS: {0}", ((int)wad.StartupIOS).ToString()); + System.Console.WriteLine("Region: {0}", wad.Region); + System.Console.WriteLine("Version: {0}", wad.TitleVersion); + System.Console.WriteLine("Blocks: {0}", wad.NandBlocks); + } + else + { + if (Quiet.quiet > 2) + System.Console.Write("Saving file..."); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".TXT") + output = output + ".txt"; + + TextWriter txt = new StreamWriter(output); + txt.WriteLine("WAD Info:"); + txt.WriteLine(""); + if (titles == false) + txt.WriteLine("Title: {0}", wad.ChannelTitles[1]); + else + { + txt.WriteLine("Titles:"); + txt.WriteLine(" Japanese: {0}", wad.ChannelTitles[0]); + txt.WriteLine(" English: {0}", wad.ChannelTitles[1]); + txt.WriteLine(" German: {0}", wad.ChannelTitles[2]); + txt.WriteLine(" French: {0}", wad.ChannelTitles[3]); + txt.WriteLine(" Spanish: {0}", wad.ChannelTitles[4]); + txt.WriteLine(" Italian: {0}", wad.ChannelTitles[5]); + txt.WriteLine(" Dutch: {0}", wad.ChannelTitles[6]); + txt.WriteLine(" Korean: {0}", wad.ChannelTitles[7]); + } + txt.WriteLine("Title ID: {0}", wad.UpperTitleID); + txt.WriteLine("IOS: {0}", ((int)wad.StartupIOS).ToString()); + txt.WriteLine("Region: {0}", wad.Region); + txt.WriteLine("Version: {0}", wad.TitleVersion); + txt.WriteLine("Blocks: {0}", wad.NandBlocks); + txt.Close(); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void Edit(string[] args) + { + //setting up variables + string input = args[2]; + string output = args[3]; + string id = ""; + int ios = -1; + string title = ""; + string lwrid = "Channel"; + bool fake = false; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-F": + fake = true; + break; + case "-ID": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No ID set"); + return; + } + id = args[i + 1]; + if (id.Length < 4) + { + System.Console.WriteLine("ERROR: ID too short"); + return; + } + id = id.Substring(0, 4); + break; + case "-TYPE": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + lwrid = args[i + 1]; + if (lwrid != "Channel" & lwrid != "DLC" & lwrid != "GameChannel" & lwrid != "HiddenChannels" & lwrid != "SystemChannels" & lwrid != "SystemTitles") + { + System.Console.WriteLine("ERROR: Unknown WAD type: {0}", lwrid); + return; + } + break; + case "-IOS": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + if (!int.TryParse(args[i + 1], out ios)) + { + Console.WriteLine("Invalid slot {0}...", args[i + 1]); + return; + } + if (ios < 0 || ios > 255) + { + Console.WriteLine("Invalid slot {0}...", ios); + return; + } + break; + case "-TITLE": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + title = args[i + 1]; + break; + } + } + + //Run main part, and check for exceptions + try + { + WAD wad = new WAD(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + wad.LoadFile(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + + if (Quiet.quiet > 2 && fake == true) + System.Console.WriteLine("FakeSigning WAD"); + wad.FakeSign = fake; + + if (id != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing channel type to: {0}", lwrid); + + if (lwrid == "Channel") + wad.ChangeTitleID(LowerTitleID.Channel, id); + if (lwrid == "DLC") + wad.ChangeTitleID(LowerTitleID.DLC, id); + if (lwrid == "GameChannel") + wad.ChangeTitleID(LowerTitleID.GameChannel, id); + if (lwrid == "HiddenChannels") + wad.ChangeTitleID(LowerTitleID.HiddenChannels, id); + if (lwrid == "SystemChannels") + wad.ChangeTitleID(LowerTitleID.SystemChannels, id); + if (lwrid == "SystemTitles") + wad.ChangeTitleID(LowerTitleID.SystemTitles, id); + } + if (ios > -1) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing startup IOS to: {0}", ios); + wad.ChangeStartupIOS(ios); + } + if (title != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing channel title to: {0}", title); + wad.ChangeChannelTitles(title); + } + + if (Quiet.quiet > 2) + System.Console.Write("Saving file..."); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAD") + output = output + ".wad"; + + wad.Save(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void Unpack(string[] args) + { + //setting up variables + string input = args[2]; + string output = args[3]; + bool cid = false; + + //Check if file exists + if (File.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open file: {0}", input); + return; + } + + //-cid argument + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-CID": + cid = true; + break; + } + } + + //Run main part, and check for exceptions + try + { + WAD wad = new WAD(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading file..."); + + wad.LoadFile(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 2) + System.Console.Write("Unpacking WAD..."); + + wad.Unpack(output, cid); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + private static void Pack(string[] args) + { + //Setting up variables + string input = args[2]; + string output = args[3]; + string id = ""; + int ios = -1; + string lwrid = "Channel"; + string title = ""; + bool fake = false; + + //Check if folder exists + if (Directory.Exists(input) == false) + { + System.Console.WriteLine("ERROR: Unable to open Folder: {0}", input); + return; + } + + for (int i = 1; i < args.Length; i++) + { + switch (args[i].ToUpper()) + { + case "-F": + fake = true; + break; + case "-ID": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No ID set"); + return; + } + id = args[i + 1]; + if (id.Length < 4) + { + System.Console.WriteLine("ERROR: ID too short"); + return; + } + id = id.Substring(0, 4); + break; + case "-TYPE": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + lwrid = args[i + 1]; + if (lwrid != "Channel" & lwrid != "DLC" & lwrid != "GameChannel" & lwrid != "HiddenChannels" & lwrid != "SystemChannels" & lwrid != "SystemTitles") + { + System.Console.WriteLine("ERROR: Unknown WAD type: {0}", lwrid); + return; + } + break; + case "-IOS": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + if (!int.TryParse(args[i + 1], out ios)) + { + Console.WriteLine("Invalid slot {0}...", args[i + 1]); + return; + } + if (ios < 0 || ios > 255) + { + Console.WriteLine("Invalid slot {0}...", ios); + return; + } + break; + case "-TITLE": + if (i + 1 >= args.Length) + { + Console.WriteLine("ERROR: No type set"); + return; + } + title = args[i + 1]; + break; + } + } + + + //Run main part, and check for exceptions + try + { + WAD wad = new WAD(); + + if (Quiet.quiet > 2) + System.Console.Write("Loading folder..."); + + wad.CreateNew(input); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + + if (Quiet.quiet > 2 && fake == true) + System.Console.WriteLine("FakeSigning WAD"); + wad.FakeSign = fake; + + if (id != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing channel type to: {0}", lwrid); + + if (lwrid == "Channel") + wad.ChangeTitleID(LowerTitleID.Channel, id); + if (lwrid == "DLC") + wad.ChangeTitleID(LowerTitleID.DLC, id); + if (lwrid == "GameChannel") + wad.ChangeTitleID(LowerTitleID.GameChannel, id); + if (lwrid == "HiddenChannels") + wad.ChangeTitleID(LowerTitleID.HiddenChannels, id); + if (lwrid == "SystemChannels") + wad.ChangeTitleID(LowerTitleID.SystemChannels, id); + if (lwrid == "SystemTitles") + wad.ChangeTitleID(LowerTitleID.SystemTitles, id); + } + if (ios > -1) + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing startup IOS to: {0}", ios); + wad.ChangeStartupIOS(ios); + } + if (title != "") + { + if (Quiet.quiet > 2) + System.Console.WriteLine("Changing channel title to: {0}", title); + wad.ChangeChannelTitles(title); + } + + if (Quiet.quiet > 2) + System.Console.Write("Saving file..."); + + if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAD") + output = output + ".wad"; + + wad.Save(output); + + if (Quiet.quiet > 2) + System.Console.Write("Done!\n"); + + if (Quiet.quiet > 1) + System.Console.WriteLine("Operation completed succesfully!"); + } + catch (Exception ex) + { + System.Console.WriteLine("An unknown error occured, please try again"); + System.Console.WriteLine(""); + System.Console.WriteLine("ERROR DETAILS: {0}", ex.Message); + return; + } + } + + public static void WAD_help() + { + System.Console.WriteLine(""); + System.Console.WriteLine("Sharpii {0} - WAD - A tool by person66, using libWiiSharp.dll by leathl", Version.version); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Usage:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Sharpii.exe WAD [-p | -u | -e | -i] input output [arguments]"); + System.Console.WriteLine(""); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" input The input file/folder"); + System.Console.WriteLine(" output The output file/folder"); + System.Console.WriteLine(" -p Pack WAD"); + System.Console.WriteLine(" -u Unpack WAD"); + System.Console.WriteLine(" -e Edit WAD"); + System.Console.WriteLine(" -i Get WAD info"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for unpacking:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -cid Use Content ID as name"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for info:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -o output Output info to text file"); + System.Console.WriteLine(" -titles Display titles in all languages"); + System.Console.WriteLine(""); + System.Console.WriteLine(" Arguments for packing/editing:"); + System.Console.WriteLine(""); + System.Console.WriteLine(" -id [TitleID] Change the 4-character title id"); + System.Console.WriteLine(" -ios [IOS] Change the Startup IOS"); + System.Console.WriteLine(" -title [title] Change the Channel name/title."); + System.Console.WriteLine(" If there are spaces, surround in quotes"); + System.Console.WriteLine(" -f Fakesign the WAD"); + System.Console.WriteLine(" -type [type] Change the Channel type. Possible values are:"); + System.Console.WriteLine(" Channel, DLC, GameChannel, HiddenChannels,"); + System.Console.WriteLine(" SystemChannels, or SystemTitles"); + } + } +} \ No newline at end of file diff --git a/Sharpii/app.config b/Sharpii/app.config new file mode 100644 index 0000000..8494f72 --- /dev/null +++ b/Sharpii/app.config @@ -0,0 +1,3 @@ + + + diff --git a/Sharpii/libWiiSharp.dll b/Sharpii/libWiiSharp.dll new file mode 100644 index 0000000..b96ffb0 Binary files /dev/null and b/Sharpii/libWiiSharp.dll differ