Initial Release, yay! ^_^

This commit is contained in:
mzolob@gmail.com 2011-09-27 03:19:01 +00:00
commit 47b787b9e8
13 changed files with 1951 additions and 0 deletions

20
Sharpii.sln Normal file
View File

@ -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

203
Sharpii/BNS.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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");
}
}
}

134
Sharpii/HBC.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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");
}
}
}

226
Sharpii/IOS.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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 #");
}
}
}

146
Sharpii/Program.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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";
}

View File

@ -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")]

100
Sharpii/Sharpii.csproj Normal file
View File

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sharpii</RootNamespace>
<AssemblyName>Sharpii</AssemblyName>
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
<TargetFrameworkProfile>
</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<UseVSHostingProcess>true</UseVSHostingProcess>
</PropertyGroup>
<ItemGroup>
<Reference Include="libWiiSharp">
<HintPath>.\libWiiSharp.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="HBC.cs" />
<Compile Include="IOS.cs" />
<Compile Include="U8.cs" />
<Compile Include="TPL.cs" />
<Compile Include="BNS.cs" />
<Compile Include="WAD.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
<Visible>False</Visible>
<ProductName>Windows Installer 3.1</ProductName>
<Install>true</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<StartArguments>
</StartArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<StartArguments>
</StartArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<PublishUrlHistory>publish\</PublishUrlHistory>
<InstallUrlHistory />
<SupportUrlHistory />
<UpdateUrlHistory />
<BootstrapperUrlHistory />
<ErrorReportUrlHistory />
<FallbackCulture>en-US</FallbackCulture>
<VerifyUploadedFiles>false</VerifyUploadedFiles>
</PropertyGroup>
</Project>

236
Sharpii/TPL.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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");
}
}
}

227
Sharpii/U8.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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");
}
}
}

595
Sharpii/WAD.cs Normal file
View File

@ -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 <http://www.gnu.org/licenses/>.
*/
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");
}
}
}

3
Sharpii/app.config Normal file
View File

@ -0,0 +1,3 @@
<?xml version="1.0"?>
<configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

BIN
Sharpii/libWiiSharp.dll Normal file

Binary file not shown.