2020-04-02 22:49:48 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-03-04 20:01:43 +00:00
|
|
|
|
using System.Diagnostics;
|
2020-04-02 22:49:48 +00:00
|
|
|
|
using System.IO;
|
2020-08-10 13:11:56 +00:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Security.Cryptography;
|
2020-04-02 22:49:48 +00:00
|
|
|
|
|
|
|
|
|
namespace UWUVCI_AIO_WPF.Classes
|
|
|
|
|
{
|
|
|
|
|
class ToolCheck
|
|
|
|
|
{
|
2020-04-17 01:28:14 +00:00
|
|
|
|
static string FolderName = "bin\\Tools";
|
2020-06-05 11:02:11 +00:00
|
|
|
|
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/";
|
2020-04-28 23:40:54 +00:00
|
|
|
|
public static string[] ToolNames =
|
2020-04-02 22:49:48 +00:00
|
|
|
|
{
|
|
|
|
|
"CDecrypt.exe",
|
|
|
|
|
"CNUSPACKER.exe",
|
|
|
|
|
"N64Converter.exe",
|
|
|
|
|
"png2tga.exe",
|
|
|
|
|
"psb.exe",
|
|
|
|
|
"RetroInject.exe",
|
|
|
|
|
"tga_verify.exe",
|
|
|
|
|
"WiiUDownloader.exe",
|
2020-04-04 22:16:55 +00:00
|
|
|
|
"wiiurpxtool.exe",
|
2020-04-04 22:30:01 +00:00
|
|
|
|
"INICreator.exe",
|
|
|
|
|
"7za.exe",
|
2020-04-06 15:51:15 +00:00
|
|
|
|
"blank.ini",
|
|
|
|
|
"FreeImage.dll",
|
2020-04-07 03:55:44 +00:00
|
|
|
|
"BuildPcePkg.exe",
|
2020-04-07 21:21:38 +00:00
|
|
|
|
"BuildTurboCdPcePkg.exe",
|
2020-04-16 04:41:25 +00:00
|
|
|
|
"goomba.gba",
|
|
|
|
|
"nfs2iso2nfs.exe",
|
|
|
|
|
"nintendont.dol",
|
|
|
|
|
"nintendont_force.dol",
|
|
|
|
|
"GetExtTypePatcher.exe",
|
|
|
|
|
"wbfs_file.exe",
|
|
|
|
|
"wit.exe",
|
|
|
|
|
"cygwin1.dll",
|
|
|
|
|
"cygz.dll",
|
|
|
|
|
"cyggcc_s-1.dll",
|
|
|
|
|
"NintendontConfig.exe",
|
2020-04-17 01:28:14 +00:00
|
|
|
|
"BASE.zip",
|
|
|
|
|
"tga2png.exe",
|
|
|
|
|
"iconTex.tga",
|
2020-04-19 19:15:00 +00:00
|
|
|
|
"wii-vmc.exe",
|
2020-04-22 00:24:35 +00:00
|
|
|
|
"bootTvTex.png",
|
|
|
|
|
"ConvertToISO.exe",
|
|
|
|
|
"NKit.dll",
|
|
|
|
|
"SharpCompress.dll",
|
2020-04-25 06:40:38 +00:00
|
|
|
|
"NKit.dll.config",
|
2020-07-29 15:24:25 +00:00
|
|
|
|
"sox.exe",
|
2020-04-28 23:40:54 +00:00
|
|
|
|
"jpg2tga.exe",
|
2020-05-04 16:20:21 +00:00
|
|
|
|
"bmp2tga.exe",
|
2020-06-01 23:36:49 +00:00
|
|
|
|
"ConvertToNKit.exe",
|
|
|
|
|
"wglp.exe",
|
2020-06-11 08:12:03 +00:00
|
|
|
|
"font.otf",
|
2020-06-13 07:27:42 +00:00
|
|
|
|
"ChangeAspectRatio.exe",
|
2020-06-13 08:11:28 +00:00
|
|
|
|
"font2.ttf",
|
2022-03-04 20:01:43 +00:00
|
|
|
|
"forwarder.dol",
|
|
|
|
|
"gba1.zip",
|
|
|
|
|
"gba2.zip"
|
2020-04-02 22:49:48 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static bool DoesToolsFolderExist()
|
|
|
|
|
{
|
|
|
|
|
if (Directory.Exists(FolderName))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-10 13:11:56 +00:00
|
|
|
|
public static bool IsToolRight(string name)
|
|
|
|
|
{
|
|
|
|
|
bool ret = false;
|
|
|
|
|
WebClient client = new WebClient();
|
|
|
|
|
client.DownloadFile(backupulr + name + ".md5", name + ".md5");
|
|
|
|
|
StreamReader sr = new StreamReader(name + ".md5");
|
|
|
|
|
var md5 = sr.ReadLine();
|
|
|
|
|
if(CalculateMD5(name) == md5)
|
|
|
|
|
{
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
sr.Close();
|
|
|
|
|
File.Delete(name + ".md5");
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
static string CalculateMD5(string filename)
|
|
|
|
|
{
|
|
|
|
|
using (var md5 = MD5.Create())
|
|
|
|
|
{
|
|
|
|
|
using (var stream = File.OpenRead(filename))
|
|
|
|
|
{
|
|
|
|
|
string ret = BitConverter.ToString(md5.ComputeHash(stream)).Replace("-", "").ToLower();
|
|
|
|
|
stream.Close();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-02 22:49:48 +00:00
|
|
|
|
public static List<MissingTool> CheckForMissingTools()
|
|
|
|
|
{
|
|
|
|
|
List<MissingTool> ret = new List<MissingTool>();
|
|
|
|
|
foreach(string s in ToolNames)
|
|
|
|
|
{
|
|
|
|
|
string path = $@"{FolderName}\{s}";
|
|
|
|
|
if (!DoesToolExist(path))
|
|
|
|
|
{
|
|
|
|
|
ret.Add(new MissingTool(s, path));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool DoesToolExist(string path)
|
|
|
|
|
{
|
2022-03-04 20:01:43 +00:00
|
|
|
|
if (!File.Exists(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
if (path.ToLower().Contains("gba1.zip"))
|
2020-04-02 22:49:48 +00:00
|
|
|
|
{
|
2022-03-04 20:01:43 +00:00
|
|
|
|
string p = Path.GetDirectoryName(path);
|
|
|
|
|
if (!File.Exists(Path.Combine(p, "MArchiveBatchTool.exe")))
|
|
|
|
|
{
|
|
|
|
|
using (Process extract = new Process())
|
|
|
|
|
{
|
|
|
|
|
extract.StartInfo.UseShellExecute = false;
|
|
|
|
|
extract.StartInfo.CreateNoWindow = false;
|
|
|
|
|
extract.StartInfo.FileName = "cmd.exe";
|
|
|
|
|
extract.StartInfo.Arguments = "/c bin\\Tools\\7za.exe x bin\\Tools\\gba1.zip -obin\\Tools";
|
|
|
|
|
extract.Start();
|
|
|
|
|
extract.WaitForExit();
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-02 22:49:48 +00:00
|
|
|
|
}
|
2022-03-04 20:01:43 +00:00
|
|
|
|
else if (path.ToLower().Contains("gba2.zip"))
|
|
|
|
|
{
|
|
|
|
|
string p = Path.GetDirectoryName(path);
|
|
|
|
|
if (!File.Exists(Path.Combine(p, "ucrtbase.dll")))
|
|
|
|
|
{
|
|
|
|
|
using (Process extract = new Process())
|
|
|
|
|
{
|
|
|
|
|
extract.StartInfo.UseShellExecute = false;
|
|
|
|
|
extract.StartInfo.CreateNoWindow = false;
|
|
|
|
|
extract.StartInfo.FileName = "cmd.exe";
|
|
|
|
|
extract.StartInfo.Arguments = "/c bin\\Tools\\7za.exe x bin\\Tools\\gba2.zip -obin\\Tools";
|
|
|
|
|
extract.Start();
|
|
|
|
|
extract.WaitForExit();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
2020-04-02 22:49:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
class MissingTool
|
|
|
|
|
{
|
|
|
|
|
public string Name { get; set; }
|
|
|
|
|
public string Path { get; set; }
|
|
|
|
|
|
|
|
|
|
public MissingTool(string n, string p)
|
|
|
|
|
{
|
|
|
|
|
this.Name = n;
|
|
|
|
|
FileInfo f = new FileInfo(p);
|
|
|
|
|
this.Path = f.FullName;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|