Windows and Linux compatible port (Mac may work but untested.)

This commit is contained in:
Shadow Eevee 2020-01-17 21:45:36 -08:00
parent 0e9e33a7c1
commit 077f97b45a
11 changed files with 215 additions and 204 deletions

View file

@ -1,8 +1,10 @@
# Sharpii - A command line libWiiSharp tool
# Fork Notes
- Status: Ported locally, but Linux and Mac compiling isn't possible yet. The ported files will be uploaded soon.
- Purpose: A .Net Core port of Sharpii for use on Mac and Linux, intended for use with my Unix rewrite of the RC24 Patcher [Put Link Here], but it can be used for any purpose when it's done.
- Status: Ported and working! Mac untested.
- Purpose: A .Net Core port of Sharpii for use on Mac and Linux, intended for use with my Unix rewrite of the RC24 Patcher but it can be used for any purpose.
- Issues/Pull Requests: All issues with this version of Sharpii should go in this fork's issue tracker. The issue is likely with the port and even if it isn't maybe I can fix it as I don't know if the original Sharpii creator is still active here. Pull requests are appreciated if they fix an issue, but it may take a bit to review.
# Repo info

27
Sharpii.csproj Normal file
View file

@ -0,0 +1,27 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="Sharpii\Properties\" />
<Folder Include="WadInstaller\Properties\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="4.1.0" />
<PackageReference Include="System.Drawing.Common" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<Reference Include="libWiiSharp">
<HintPath>Sharpii\libWiiSharp.dll</HintPath>
</Reference>
<Reference Include="WadInstaller">
<HintPath>Sharpii\WadInstaller.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

View file

@ -1,42 +1,25 @@

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
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WadInstaller", "WadInstaller\WadInstaller.csproj", "{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}"
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29709.97
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sharpii", "Sharpii.csproj", "{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|Mixed Platforms = Debug|Mixed Platforms
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|Mixed Platforms = Release|Mixed Platforms
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Debug|Any CPU.ActiveCfg = Debug|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Debug|Mixed Platforms.Build.0 = Debug|x86
{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|Any CPU.ActiveCfg = Release|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|Mixed Platforms.ActiveCfg = Release|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|Mixed Platforms.Build.0 = Release|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|x86.ActiveCfg = Release|x86
{AD7EBA1D-DF9F-4F71-AAD4-3963E79CE827}.Release|x86.Build.0 = Release|x86
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Debug|x86.ActiveCfg = Debug|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Any CPU.Build.0 = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{475F3ADF-B529-449F-89DA-BA5E8BE15DD5}.Release|x86.ActiveCfg = Release|Any CPU
{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A5ABD4DA-DBAB-4304-BEB1-A52BC9D6516D}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {D7A37F7C-1238-497F-8B97-F238108BBB4B}
EndGlobalSection
EndGlobal

View file

@ -63,15 +63,15 @@ namespace Sharpii
try
{
//Now convert it
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
Wave WavFile = libWiiSharp.BNS.BnsToWave(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving wav...");
if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAV")
@ -79,10 +79,10 @@ namespace Sharpii
WavFile.Save(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -130,28 +130,28 @@ namespace Sharpii
//Run main part, and check for exceptions
try
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
BNS WavFile = new BNS(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (loop == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Applying loop");
WavFile.SetLoop(1);
}
if (mono == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Converting to mono");
WavFile.StereoToMono = true;
}
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving BNS...");
WavFile.Convert();
@ -161,10 +161,10 @@ namespace Sharpii
WavFile.Save(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -179,7 +179,7 @@ namespace Sharpii
public static void Wav2BNS_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - BNS - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - BNS - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -19,7 +19,6 @@ using System;
using System.IO;
using System.Net;
using libWiiSharp;
using System.Windows.Forms;
namespace Sharpii
{
@ -99,7 +98,7 @@ namespace Sharpii
{
if (ip != "" && saveip == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Saving IP");
Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
}
@ -113,40 +112,40 @@ namespace Sharpii
Console.WriteLine("ERROR: No IP set");
return;
}
if (noip == true && Quiet.quiet > 2)
if (noip == true && BeQuiet.quiet > 2)
Console.WriteLine("No IP set, using {0}", ip);
libWiiSharp.Protocol proto = Protocol.JODI;
if (Quiet.quiet > 2 && protocol == "HAXX")
if (BeQuiet.quiet > 2 && protocol == "HAXX")
Console.WriteLine("Using old protocol");
if (protocol == "HAXX")
proto = Protocol.HAXX;
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading File...");
HbcTransmitter file = new HbcTransmitter(proto, ip);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 2 && compress == true)
if (BeQuiet.quiet > 2 && compress == true)
Console.Write("Compressing File...");
file.Compress = compress;
if (Quiet.quiet > 2 && compress == true)
if (BeQuiet.quiet > 2 && compress == true)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Sending file...");
file.TransmitFile(Path.GetFileName(input) + arguments, File.ReadAllBytes(input));
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Done!\n");
}
catch (Exception ex)
@ -174,7 +173,7 @@ namespace Sharpii
return false;
}
if (!File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll"))
if (!File.Exists(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\WadInstaller.dll"))
{
Console.WriteLine("ERROR: WadInstaller.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]");
@ -186,7 +185,7 @@ namespace Sharpii
{
Console.Write("\nGrabbing WadInstaller.dll...");
WebClient DLwadInstaller = new WebClient();
DLwadInstaller.DownloadFile("https://github.com/mogzol/sharpii/raw/master/Sharpii/WadInstaller.dll", Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll");
DLwadInstaller.DownloadFile("https://github.com/mogzol/sharpii/raw/master/Sharpii/WadInstaller.dll", Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\WadInstaller.dll");
Console.Write("Done!\n");
}
catch (Exception ex)
@ -267,14 +266,14 @@ namespace Sharpii
{
if (ip != "" && saveip == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Saving IP");
Environment.SetEnvironmentVariable("SharpiiIP", ip, EnvironmentVariableTarget.Machine);
}
if (ahb == true || ios == "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Using AHBPROT");
ios = "0";
}
@ -288,32 +287,32 @@ namespace Sharpii
Console.WriteLine("ERROR: No IP set");
return;
}
if (noip == true && Quiet.quiet > 2)
if (noip == true && BeQuiet.quiet > 2)
Console.WriteLine("No IP set, using {0}", ip);
libWiiSharp.Protocol proto = Protocol.JODI;
if (Quiet.quiet > 2 && protocol == "HAXX")
if (BeQuiet.quiet > 2 && protocol == "HAXX")
Console.WriteLine("Using old protocol");
if (protocol == "HAXX")
proto = Protocol.HAXX;
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading File...");
HbcTransmitter file = new HbcTransmitter(proto, ip);
byte[] Installer = WadInstaller.InstallerHelper.CreateInstaller(input, (byte)Convert.ToInt32(ios)).ToArray();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Sending file...");
file.TransmitFile("WadInstaller.dol", Installer);
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Done!\n");
}
catch (Exception ex)
@ -331,7 +330,7 @@ namespace Sharpii
private static void SendDol_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - SendDol - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - SendDol - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");
@ -356,7 +355,7 @@ namespace Sharpii
public static void SendWad_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - SendWad - A tool by person66, using libWiiSharp.dll by leathl,", Version.version);
Console.WriteLine("Sharpii {0} - SendWad - A tool by person66, using libWiiSharp.dll by leathl,", ProgramVersion.version);
Console.WriteLine(" and CRAP's installer by WiiCrazy/I.R.on");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -131,12 +131,12 @@ namespace Sharpii
WAD ios = new WAD();
ios.KeepOriginalFooter = true;
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading File...");
ios.LoadFile(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
//Check if WAD is an IOS
@ -153,28 +153,28 @@ namespace Sharpii
//apply patches
if (fs == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Applying Fakesigning patch");
patcher.PatchFakeSigning();
}
if (es == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Applying ES_Identify patch");
patcher.PatchEsIdentify();
}
if (np == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Applying NAND permissions patch");
patcher.PatchNandPermissions();
}
if (vp == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Applying Version patch");
patcher.PatchVP();
}
@ -184,14 +184,14 @@ namespace Sharpii
if (slot > -1)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing IOS slot to: {0}", slot);
ios.TitleID = (ulong)((1UL << 32) | (uint)slot);
}
if (version > -1)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing title version to: {0}", version);
ios.TitleVersion = (ushort)version;
}
@ -199,13 +199,13 @@ namespace Sharpii
//check if output was set
if (output != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Saving to file: {0}", output);
ios.Save(output);
}
else
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving file...");
if (output != "")
@ -216,10 +216,10 @@ namespace Sharpii
ios.Save(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
}
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -237,7 +237,7 @@ namespace Sharpii
public static void IOS_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - IOS - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - IOS - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine(" Code based off PatchIOS by leathl");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -175,7 +175,7 @@ namespace Sharpii
if (version == "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("No version specified, using latest", version);
version = "LATEST";
}
@ -187,14 +187,14 @@ namespace Sharpii
TMD tmd = grabtmd.DownloadTMD(id, "");
version = tmd.TitleVersion.ToString();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Found latest version: v{0}", version);
}
if (entered == false) //Will only be false if no store type argument was given
{
store.Add(StoreType.All);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("No store type specified, using all");
}
@ -205,7 +205,7 @@ namespace Sharpii
{
wad = true;
if (Directory.Exists(temp) == true)
DeleteDir.DeleteDirectory(temp);
DeleteADir.DeleteDirectory(temp);
Directory.CreateDirectory(temp);
}
@ -214,7 +214,7 @@ namespace Sharpii
{
NoOut = true;
output = ios == "" ? id + "v" + version : ios.Substring(0, ios.Length - 4);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("No output specified, using {0}", output);
}
@ -225,7 +225,7 @@ namespace Sharpii
if (local == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Using local files if present...");
nus.UseLocalFiles = true;
}
@ -233,17 +233,17 @@ namespace Sharpii
if (content != "")
{
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Downloading content...");
nus.DownloadSingleContent(id, version, content, output);
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Done!\n");
}
else
{
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Downloading title...");
string realout = output;
@ -254,11 +254,11 @@ namespace Sharpii
WadIosNamingStuff(wad, temp, id, version, ios, NoOut, output, realout);
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.Write("Done!\n");
}
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -301,7 +301,7 @@ namespace Sharpii
File.Delete(realout);
File.Move(temp + "\\" + id + "v" + version + ".wad", realout);
}
DeleteDir.DeleteDirectory(temp);
DeleteADir.DeleteDirectory(temp);
}
else if (ios != "")
{
@ -319,7 +319,7 @@ namespace Sharpii
public static void NUS_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - NUSD - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - NUSD - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -19,7 +19,6 @@ using System;
using System.IO;
using System.Net;
using libWiiSharp;
using System.Windows.Forms;
using System.Diagnostics;
namespace Sharpii
@ -34,10 +33,10 @@ namespace Sharpii
Environment.Exit(0);
}
if (!File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll"))
if (!File.Exists(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + Path.DirectorySeparatorChar + "libWiiSharp.dll"))
{
Console.WriteLine("ERROR: libWiiSharp.dll not found");
Console.WriteLine("\n\nAttemp to download? [Y/N]");
Console.WriteLine("\n\nAttempt to download? [Y/N]");
Console.Write("\n>>");
string ans = Console.ReadLine();
if (ans.ToUpper() == "Y")
@ -46,7 +45,7 @@ namespace Sharpii
{
Console.Write("\nGrabbing libWiiSharp.dll...");
WebClient DLlibWiiSharp = new WebClient();
DLlibWiiSharp.DownloadFile("https://github.com/mogzol/sharpii/raw/master/Sharpii/libWiiSharp.dll", Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll");
DLlibWiiSharp.DownloadFile("https://github.com/mogzol/sharpii/raw/master/Sharpii/libWiiSharp.dll", Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\libWiiSharp.dll");
Console.Write("Done!\n");
}
catch (Exception ex)
@ -61,13 +60,13 @@ namespace Sharpii
switch (args[i].ToUpper())
{
case "-QUIET":
Quiet.quiet = 1;
BeQuiet.quiet = 1;
break;
case "-Q":
Quiet.quiet = 1;
BeQuiet.quiet = 1;
break;
case "-LOTS":
Quiet.quiet = 3;
BeQuiet.quiet = 3;
break;
}
}
@ -159,7 +158,7 @@ namespace Sharpii
string temp = Path.GetTempPath() + "Sharpii.tmp";
if (Directory.Exists(temp) == true)
DeleteDir.DeleteDirectory(temp);
DeleteADir.DeleteDirectory(temp);
Environment.Exit(0);
}
@ -168,28 +167,28 @@ namespace Sharpii
{
try
{
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Installing Sharpii...");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Adding Variables");
Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine) +
";" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\", EnvironmentVariableTarget.Machine);
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Creating Directory");
if (Directory.Exists(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\"))
DeleteDir.DeleteDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
DeleteADir.DeleteDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Copying Files");
File.Copy(Application.ExecutablePath, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\Sharpii.exe");
if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll"))
File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\libWiiSharp.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\libWiiSharp.dll");
if (File.Exists(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll"))
File.Copy(Path.GetDirectoryName(Application.ExecutablePath) + "\\WadInstaller.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\WadInstaller.dll");
File.Copy(AppDomain.CurrentDomain.BaseDirectory, Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\Sharpii.exe");
if (File.Exists(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\libWiiSharp.dll"))
File.Copy(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\libWiiSharp.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\libWiiSharp.dll");
if (File.Exists(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\WadInstaller.dll"))
File.Copy(Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory) + "\\WadInstaller.dll", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\WadInstaller.dll");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
{
Console.WriteLine("Sharpii was successfully installed to: {0}", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\");
Console.WriteLine("You can now use Sharpii in any directory!");
@ -208,13 +207,13 @@ namespace Sharpii
{
try
{
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Uninstalling Sharpii...");
string path = Environment.GetEnvironmentVariable("PATH", EnvironmentVariableTarget.Machine);
Environment.SetEnvironmentVariable("PATH", path.Replace(";" + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\", ""), EnvironmentVariableTarget.Machine);
Process.Start("cmd.exe", "/C mode con:cols=50 lines=4 & color 0B & echo Finishing Uninstallation... & sleep 2 & rmdir /s /q " + '"' +
Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\Sharpii\\" + '"' + " & CLS & echo Sharpii has been successfully uninstalled! & echo. & pause");
Application.Exit();
Environment.Exit(0);
}
catch (Exception ex)
{
@ -247,7 +246,7 @@ namespace Sharpii
private static void help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");
@ -288,38 +287,39 @@ namespace Sharpii
}
}
public class DeleteDir
public class DeleteADir
{
public static bool DeleteDirectory(string target_dir)
{
public static bool DeleteDirectory(string target_dir)
bool result = false;
string[] files = Directory.GetFiles(target_dir);
string[] dirs = Directory.GetDirectories(target_dir);
foreach (string file in files)
{
bool result = false;
string[] files = Directory.GetFiles(target_dir);
string[] dirs = Directory.GetDirectories(target_dir);
foreach (string file in files)
{
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
{
DeleteDirectory(dir);
}
Directory.Delete(target_dir, false);
return result;
File.SetAttributes(file, FileAttributes.Normal);
File.Delete(file);
}
foreach (string dir in dirs)
{
DeleteDirectory(dir);
}
Directory.Delete(target_dir, false);
return result;
}
public class Quiet {
//1 = little
//2 = normal
//3 = lots
public static int quiet = 2;
}
public class Version
{
public static string version = "1.7.3";
}
}
public class BeQuiet
{
//1 = little
//2 = normal
//3 = lots
public static int quiet = 2;
}
public class ProgramVersion
{
public static string version = "1.7.3; .Net Core Port";
}

View file

@ -67,24 +67,24 @@ namespace Sharpii
try
{
//Load tpl
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
TPL tplfile = libWiiSharp.TPL.Load(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
//save image
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Extracting texture...");
tplfile.ExtractTexture(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -162,20 +162,20 @@ namespace Sharpii
if (tplFormat == "RGBA8")
format = TPL_TextureFormat.RGBA8;
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Format set to: {0}", tplFormat);
//Make tpl
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Creating tpl file...");
TPL tplfile = libWiiSharp.TPL.FromImage(input, format);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
//save
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving tpl file...");
if (output.Substring(output.Length - 4, 4).ToUpper() != ".TPL")
@ -183,10 +183,10 @@ namespace Sharpii
tplfile.Save(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -201,7 +201,7 @@ namespace Sharpii
public static void TPL_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - TPL - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - TPL - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -75,23 +75,23 @@ namespace Sharpii
//Load U8
U8 U8file = new U8();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
U8file.LoadFile(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Extracting file...");
U8file.Extract(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -151,24 +151,24 @@ namespace Sharpii
{
U8 U8folder = new U8();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading folder...");
U8folder.CreateFromDirectory(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (imd5 == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Adding IMD5 Header");
U8folder.AddHeaderImd5();
}
if (imet != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Adding IMET header with title: {0}", imet);
U8folder.AddHeaderImet(false, imet);
}
@ -176,17 +176,17 @@ namespace Sharpii
if (lz77 == true)
{
//Yeah, I know this isnt where it actually compresses it
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Compressing U8 archive");
U8folder.Lz77Compress = true;
}
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Saving file");
U8folder.Save(output);
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -201,7 +201,7 @@ namespace Sharpii
public static void U8_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - U8 - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - U8 - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");

View file

@ -126,15 +126,15 @@ namespace Sharpii
{
WAD wad = new WAD();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
wad.LoadFile(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1 && output == "")
if (BeQuiet.quiet > 1 && output == "")
{
Console.WriteLine("WAD Info:");
Console.WriteLine("");
@ -161,7 +161,7 @@ namespace Sharpii
}
else
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving file...");
if (output.Substring(output.Length - 4, 4).ToUpper() != ".TXT")
@ -192,10 +192,10 @@ namespace Sharpii
txt.WriteLine("Blocks: {0}", wad.NandBlocks);
txt.Close();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
}
@ -358,25 +358,25 @@ namespace Sharpii
if (edit == true)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
wad.LoadFile(input);
}
else
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading folder...");
wad.CreateNew(input);
}
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (sound != "" || banner != "" || icon != "" || app != "")
{
string temp = Path.GetTempPath() + "Sharpii.tmp";
if (Directory.Exists(temp) == true)
DeleteDir.DeleteDirectory(temp);
DeleteADir.DeleteDirectory(temp);
Directory.CreateDirectory(temp);
@ -389,7 +389,7 @@ namespace Sharpii
if (sound != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Grabbing sound...");
twad.LoadFile(sound);
@ -400,12 +400,12 @@ namespace Sharpii
File.Copy(temp + "\\sound\\00000000\\meta\\sound.bin", temp + "\\main\\00000000\\meta\\sound.bin", true);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
}
if (banner != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Grabbing banner...");
twad.LoadFile(banner);
@ -416,12 +416,12 @@ namespace Sharpii
File.Copy(temp + "\\banner\\00000000\\meta\\banner.bin", temp + "\\main\\00000000\\meta\\banner.bin", true);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
}
if (icon != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Grabbing icon...");
twad.LoadFile(icon);
@ -432,12 +432,12 @@ namespace Sharpii
File.Copy(temp + "\\icon\\00000000\\meta\\icon.bin", temp + "\\main\\00000000\\meta\\icon.bin", true);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
}
if (app != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Grabbing dol...");
if (app.Substring(app.Length - 4, 4) == ".dol")
@ -453,19 +453,19 @@ namespace Sharpii
File.Copy(temp + "\\dol\\00000001.app", temp + "\\main\\00000001.app", true);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
}
u.ReplaceFile(1, temp + "\\main\\00000000\\meta\\banner.bin");
u.ReplaceFile(2, temp + "\\main\\00000000\\meta\\icon.bin");
u.ReplaceFile(3, temp + "\\main\\00000000\\meta\\sound.bin");
u.Save(temp + "\\main\\00000000.app");
DeleteDir.DeleteDirectory(temp + "\\main\\00000000\\");
DeleteADir.DeleteDirectory(temp + "\\main\\00000000\\");
wad.CreateNew(temp + "\\main");
DeleteDir.DeleteDirectory(temp);
DeleteADir.DeleteDirectory(temp);
}
if (Quiet.quiet > 2 && fake == true)
if (BeQuiet.quiet > 2 && fake == true)
Console.WriteLine("FakeSigning WAD");
wad.FakeSign = fake;
@ -473,7 +473,7 @@ namespace Sharpii
{
if (id != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing channel ID to: {0}", id);
}
else
@ -483,7 +483,7 @@ namespace Sharpii
if (lwrid != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing channel type to: {0}", lwrid);
}
else
@ -506,18 +506,18 @@ namespace Sharpii
}
if (ios > -1)
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing startup IOS to: {0}", ios);
wad.ChangeStartupIOS(ios);
}
if (title != "")
{
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.WriteLine("Changing channel title to: {0}", title);
wad.ChangeChannelTitles(title);
}
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Saving file...");
if (output.Substring(output.Length - 4, 4).ToUpper() != ".WAD")
@ -525,10 +525,10 @@ namespace Sharpii
wad.Save(output);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -570,23 +570,23 @@ namespace Sharpii
{
WAD wad = new WAD();
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Loading file...");
wad.LoadFile(input);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Unpacking WAD...");
wad.Unpack(output, cid);
if (Quiet.quiet > 2)
if (BeQuiet.quiet > 2)
Console.Write("Done!\n");
if (Quiet.quiet > 1)
if (BeQuiet.quiet > 1)
Console.WriteLine("Operation completed succesfully!");
}
catch (Exception ex)
@ -601,7 +601,7 @@ namespace Sharpii
public static void WAD_help()
{
Console.WriteLine("");
Console.WriteLine("Sharpii {0} - WAD - A tool by person66, using libWiiSharp.dll by leathl", Version.version);
Console.WriteLine("Sharpii {0} - WAD - A tool by person66, using libWiiSharp.dll by leathl", ProgramVersion.version);
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine(" Usage:");