WiiWare/Channel Forwarding

This commit is contained in:
NicoAICP 2020-06-13 10:11:28 +02:00
parent ad792cedc2
commit be32f69da3
4 changed files with 150 additions and 4 deletions

View file

@ -409,6 +409,9 @@ namespace UWUVCI_AIO_WPF
if (RomPath.ToLower().EndsWith(".dol"))
{
WiiHomebrew(RomPath, mvm);
}else if (RomPath.ToLower().EndsWith(".wad"))
{
WiiForwarder(RomPath, mvm);
}
else
{
@ -421,6 +424,129 @@ namespace UWUVCI_AIO_WPF
break;
}
}
private static string ByteArrayToString(byte[] arr)
{
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
return enc.GetString(arr);
}
private static void WiiForwarder(string romPath, MainViewModel mvm)
{
string savedir = Directory.GetCurrentDirectory();
mvvm.msg = "Extracting Forwarder Base...";
if (Directory.Exists(Path.Combine(tempPath, "TempBase"))) Directory.Delete(Path.Combine(tempPath, "TempBase"), true);
Directory.CreateDirectory(Path.Combine(tempPath, "TempBase"));
using (Process zip = new Process())
{
if (!mvm.debug)
{
zip.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
}
zip.StartInfo.FileName = Path.Combine(toolsPath, "7za.exe");
zip.StartInfo.Arguments = $"x \"{Path.Combine(toolsPath, "BASE.zip")}\" -o\"{Path.Combine(tempPath)}\"";
zip.Start();
zip.WaitForExit();
}
DirectoryCopy(Path.Combine(tempPath, "BASE"), Path.Combine(tempPath, "TempBase"), true);
mvvm.Progress = 20;
mvvm.msg = "Setting up Forwarder...";
byte[] test = new byte[4];
using (FileStream fs = new FileStream(romPath, FileMode.Open))
{
fs.Seek(0xC20, SeekOrigin.Begin);
fs.Read(test, 0, 4);
fs.Close();
}
string[] id = { ByteArrayToString(test) };
File.WriteAllLines(Path.Combine(tempPath, "TempBase", "files","title.txt"), id);
mvm.Progress = 30;
mvm.msg = "Copying Forwarder...";
File.Copy(Path.Combine(toolsPath, "forwarder.dol"), Path.Combine(tempPath, "TempBase", "sys", "main.dol"));
mvm.Progress = 40;
mvvm.msg = "Creating Injectable file...";
using (Process wit = new Process())
{
if (!mvm.debug)
{
wit.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
}
wit.StartInfo.FileName = Path.Combine(toolsPath, "wit.exe");
wit.StartInfo.Arguments = $"copy \"{Path.Combine(tempPath, "TempBase")}\" --DEST \"{Path.Combine(tempPath, "game.iso")}\" -ovv --links --iso";
wit.Start();
wit.WaitForExit();
}
Thread.Sleep(6000);
if (!File.Exists(Path.Combine(tempPath, "game.iso")))
{
Console.Clear();
throw new Exception("WIIAn error occured while Creating the ISO");
}
Directory.Delete(Path.Combine(tempPath, "TempBase"), true);
romPath = Path.Combine(tempPath, "game.iso");
mvvm.Progress = 50;
mvm.msg = "Replacing TIK and TMD...";
using (Process extract = new Process())
{
if (!mvm.debug)
{
extract.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
}
extract.StartInfo.FileName = Path.Combine(toolsPath, "wit.exe");
extract.StartInfo.Arguments = $"extract \"{Path.Combine(tempPath, "game.iso")}\" --psel data --files +tmd.bin --files +ticket.bin --DEST \"{Path.Combine(tempPath, "TIKTMD")}\" -vv1";
extract.Start();
extract.WaitForExit();
foreach (string sFile in Directory.GetFiles(Path.Combine(baseRomPath, "code"), "rvlt.*"))
{
File.Delete(sFile);
}
File.Copy(Path.Combine(tempPath, "TIKTMD", "tmd.bin"), Path.Combine(baseRomPath, "code", "rvlt.tmd"));
File.Copy(Path.Combine(tempPath, "TIKTMD", "ticket.bin"), Path.Combine(baseRomPath, "code", "rvlt.tik"));
Directory.Delete(Path.Combine(tempPath, "TIKTMD"), true);
}
mvm.Progress = 60;
mvm.msg = "Injecting ROM...";
foreach (string sFile in Directory.GetFiles(Path.Combine(baseRomPath, "content"), "*.nfs"))
{
File.Delete(sFile);
}
File.Move(Path.Combine(tempPath, "game.iso"), Path.Combine(baseRomPath, "content", "game.iso"));
File.Copy(Path.Combine(toolsPath, "nfs2iso2nfs.exe"), Path.Combine(baseRomPath, "content", "nfs2iso2nfs.exe"));
Directory.SetCurrentDirectory(Path.Combine(baseRomPath, "content"));
using (Process iso2nfs = new Process())
{
if (!mvm.debug)
{
iso2nfs.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
}
iso2nfs.StartInfo.FileName = "nfs2iso2nfs.exe";
string extra = "";
if (mvm.Index == 2)
{
extra = "-horizontal ";
}
if (mvm.Index == 3) { extra = "-wiimote "; }
if (mvm.Index == 4) { extra = "-instantcc "; }
if (mvm.Index == 5) { extra = "-nocc "; }
if (mvm.LR) { extra += "-lrpatch "; }
iso2nfs.StartInfo.Arguments = $"-enc -homebrew {extra}-iso game.iso";
iso2nfs.Start();
iso2nfs.WaitForExit();
File.Delete("nfs2iso2nfs.exe");
File.Delete("game.iso");
}
Directory.SetCurrentDirectory(savedir);
mvm.Progress = 80;
}
private static void WiiHomebrew(string romPath, MainViewModel mvm)
{

View file

@ -57,7 +57,8 @@ namespace UWUVCI_AIO_WPF.Classes
"wglp.exe",
"font.otf",
"ChangeAspectRatio.exe",
"font2.ttf"
"font2.ttf",
"forwarder.dol"
};
public static bool DoesToolsFolderExist()

View file

@ -878,6 +878,7 @@ namespace UWUVCI_AIO_WPF
Progress = 0;
string extra = "";
if (GameConfiguration.Console == GameConsoles.WII) extra = "\nSome games cannot reboot into the WiiU Menu. Shut down via the GamePad.\nIf Stuck in a BlackScreen, you need to unplug your WiiU.";
if (GameConfiguration.Console == GameConsoles.WII && romPath.ToLower().Contains(".wad")) extra += "\nMake sure that the chosen WAD is installed in your vWii!";
if (GC) extra = "\nMake sure to have Nintendon't + config on your SD.\nYou can add them by pressing the \"SD Setup\" button or using the \"Start Nintendont Config Tool\" button under Settings.";
gc2rom = "";
Custom_Message cm = new Custom_Message("Injection Complete", $"It's recommended to install onto USB to avoid brick risks.{extra}\nTo Open the Location of the Inject press Open Folder.\nIf you want the inject to be put on your SD now, press SD Setup.", Settings.Default.OutPath); try
@ -1456,7 +1457,7 @@ namespace UWUVCI_AIO_WPF
}
else
{
dialog.Filter = "Wii ROM (*.iso; *.wbfs; *.nkit.iso; *.nkit.gcz) | *.iso; *.wbfs; *.nkit.iso; *.nkit.gcz |Wii Homebrew (*.dol) | *.dol";
dialog.Filter = "Wii ROM (*.iso; *.wbfs; *.nkit.iso; *.nkit.gcz) | *.iso; *.wbfs; *.nkit.iso; *.nkit.gcz |Wii Homebrew (*.dol) | *.dol |Wii Channel (*.wad) | *.wad";
}
break;

View file

@ -120,7 +120,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
{
int TitleIDInt = 0;
bool isok = false;
if (path.ToLower().Contains(".gcz") || path.ToLower().Contains(".dol"))
if (path.ToLower().Contains(".gcz") || path.ToLower().Contains(".dol") || path.ToLower().Contains(".wad"))
{
isok = true;
}
@ -152,6 +152,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
{
motepass.IsEnabled = false;
motepass.IsChecked = false;
gamepad.IsEnabled = true;
mvm.NKITFLAG = false;
trimn.IsEnabled = false;
trimn.IsChecked = false;
@ -177,7 +178,7 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
mvm.CanInject = true;
}
if (!path.ToLower().Contains(".gcz") && !path.ToLower().Contains(".dol"))
if (!path.ToLower().Contains(".gcz") && !path.ToLower().Contains(".dol") && !path.ToLower().Contains(".wad"))
{
string rom = mvm.getInternalWIIGCNName(mvm.RomPath, false);
Regex reg = new Regex("[*'\",_&#^@:;?!<>|µ~#°²³´`éⓇ©™]");
@ -214,6 +215,23 @@ namespace UWUVCI_AIO_WPF.UI.Frames.InjectFrames.Configurations
motepass.IsChecked = false;
motepass.IsEnabled = true;
mvm.donttrim = false;
gamepad.IsEnabled = false;
LR.IsEnabled = false;
}else if (path.ToLower().Contains(".wad"))
{
mvm.NKITFLAG = false;
trimn.IsEnabled = false;
trimn.IsChecked = false;
vmcsmoll.IsEnabled = false;
pal.IsEnabled = false;
ntsc.IsEnabled = false;
RF_n.IsEnabled = false;
RF_tj.IsEnabled = false;
RF_tn.IsEnabled = false;
RF_tp.IsEnabled = false;
jppatch.IsEnabled = false;
mvm.donttrim = false;
}
else
{