2020-04-03 00:49:48 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2022-03-04 12:01:43 -08:00
|
|
|
|
using System.Diagnostics;
|
2020-04-03 00:49:48 +02:00
|
|
|
|
using System.IO;
|
2022-07-27 10:10:01 -07:00
|
|
|
|
using System.IO.Compression;
|
2020-08-10 15:11:56 +02:00
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Security.Cryptography;
|
2022-07-27 10:10:01 -07:00
|
|
|
|
using System.Threading;
|
2022-06-30 10:58:17 -07:00
|
|
|
|
using System.Threading.Tasks;
|
2020-04-03 00:49:48 +02:00
|
|
|
|
|
|
|
|
|
namespace UWUVCI_AIO_WPF.Classes
|
|
|
|
|
{
|
|
|
|
|
class ToolCheck
|
|
|
|
|
{
|
2022-07-27 10:10:01 -07:00
|
|
|
|
static string FolderName = new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\Tools";
|
2020-06-05 13:02:11 +02:00
|
|
|
|
public static string backupulr = @"https://github.com/Hotbrawl20/UWUVCI-Tools/raw/master/";
|
2020-04-29 01:40:54 +02:00
|
|
|
|
public static string[] ToolNames =
|
2020-04-03 00:49:48 +02:00
|
|
|
|
{
|
|
|
|
|
"CDecrypt.exe",
|
|
|
|
|
"CNUSPACKER.exe",
|
|
|
|
|
"N64Converter.exe",
|
|
|
|
|
"png2tga.exe",
|
|
|
|
|
"psb.exe",
|
|
|
|
|
"RetroInject.exe",
|
|
|
|
|
"tga_verify.exe",
|
|
|
|
|
"WiiUDownloader.exe",
|
2020-04-05 00:16:55 +02:00
|
|
|
|
"wiiurpxtool.exe",
|
2020-04-05 00:30:01 +02:00
|
|
|
|
"INICreator.exe",
|
2020-04-06 17:51:15 +02:00
|
|
|
|
"blank.ini",
|
|
|
|
|
"FreeImage.dll",
|
2020-04-07 05:55:44 +02:00
|
|
|
|
"BuildPcePkg.exe",
|
2020-04-07 23:21:38 +02:00
|
|
|
|
"BuildTurboCdPcePkg.exe",
|
2020-04-16 06:41:25 +02: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 03:28:14 +02:00
|
|
|
|
"BASE.zip",
|
|
|
|
|
"tga2png.exe",
|
|
|
|
|
"iconTex.tga",
|
2020-04-19 21:15:00 +02:00
|
|
|
|
"wii-vmc.exe",
|
2020-04-22 02:24:35 +02:00
|
|
|
|
"bootTvTex.png",
|
|
|
|
|
"ConvertToISO.exe",
|
|
|
|
|
"NKit.dll",
|
|
|
|
|
"SharpCompress.dll",
|
2020-04-25 08:40:38 +02:00
|
|
|
|
"NKit.dll.config",
|
2020-07-29 17:24:25 +02:00
|
|
|
|
"sox.exe",
|
2020-04-29 01:40:54 +02:00
|
|
|
|
"jpg2tga.exe",
|
2020-05-04 18:20:21 +02:00
|
|
|
|
"bmp2tga.exe",
|
2020-06-02 01:36:49 +02:00
|
|
|
|
"ConvertToNKit.exe",
|
|
|
|
|
"wglp.exe",
|
2020-06-11 10:12:03 +02:00
|
|
|
|
"font.otf",
|
2020-06-13 09:27:42 +02:00
|
|
|
|
"ChangeAspectRatio.exe",
|
2020-06-13 10:11:28 +02:00
|
|
|
|
"font2.ttf",
|
2022-03-04 12:01:43 -08:00
|
|
|
|
"forwarder.dol",
|
|
|
|
|
"gba1.zip",
|
|
|
|
|
"gba2.zip"
|
2020-04-03 00:49:48 +02:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public static bool DoesToolsFolderExist()
|
|
|
|
|
{
|
2022-07-28 15:34:47 -07:00
|
|
|
|
return Directory.Exists(FolderName);
|
2020-04-03 00:49:48 +02:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-28 15:34:47 -07:00
|
|
|
|
public static async Task<bool> IsToolRightAsync(string name)
|
2020-08-10 15:11:56 +02:00
|
|
|
|
{
|
|
|
|
|
bool ret = false;
|
2022-07-27 10:10:01 -07:00
|
|
|
|
string md5Name = FolderName + "\\" + name + ".md5";
|
|
|
|
|
using (WebClient client = new WebClient())
|
2020-08-10 15:11:56 +02:00
|
|
|
|
{
|
2022-07-27 10:10:01 -07:00
|
|
|
|
await client.DownloadFileTaskAsync(backupulr + md5Name, md5Name);
|
|
|
|
|
using (StreamReader sr = new StreamReader(md5Name))
|
|
|
|
|
{
|
|
|
|
|
var md5 = sr.ReadLine();
|
|
|
|
|
if (CalculateMD5(name) == md5)
|
|
|
|
|
{
|
|
|
|
|
ret = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//Dumb solution but whatever, hopefully this deletes the md5file
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
File.Delete(md5Name);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
File.Delete(new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\Tools\\" + md5Name);
|
|
|
|
|
}
|
|
|
|
|
catch { }
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
File.Delete(new FileInfo(System.Reflection.Assembly.GetEntryAssembly().Location).DirectoryName + "\\bin\\bases\\" + md5Name);
|
2020-08-10 15:11:56 +02:00
|
|
|
|
}
|
2022-07-27 10:10:01 -07:00
|
|
|
|
catch { }
|
2020-08-10 15:11:56 +02:00
|
|
|
|
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();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-04-03 00:49:48 +02:00
|
|
|
|
public static List<MissingTool> CheckForMissingTools()
|
|
|
|
|
{
|
|
|
|
|
List<MissingTool> ret = new List<MissingTool>();
|
2022-07-28 15:34:47 -07:00
|
|
|
|
foreach (string s in ToolNames)
|
2020-04-03 00:49:48 +02:00
|
|
|
|
{
|
|
|
|
|
string path = $@"{FolderName}\{s}";
|
|
|
|
|
if (!DoesToolExist(path))
|
|
|
|
|
{
|
|
|
|
|
ret.Add(new MissingTool(s, path));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static bool DoesToolExist(string path)
|
|
|
|
|
{
|
2022-03-04 12:01:43 -08:00
|
|
|
|
if (!File.Exists(path))
|
|
|
|
|
return false;
|
|
|
|
|
|
2022-07-27 10:10:01 -07:00
|
|
|
|
if (path.ToLower().Contains("gba1.zip") || path.ToLower().Contains("gba2.zip"))
|
|
|
|
|
if (!File.Exists(Path.Combine(FolderName, "MArchiveBatchTool.exe")) || !File.Exists(Path.Combine(FolderName, "ucrtbase.dll")))
|
|
|
|
|
try
|
2022-03-04 12:01:43 -08:00
|
|
|
|
{
|
2022-07-27 10:10:01 -07:00
|
|
|
|
ZipFile.ExtractToDirectory(path, FolderName);
|
2022-03-04 12:01:43 -08:00
|
|
|
|
}
|
2022-07-27 10:10:01 -07:00
|
|
|
|
catch (Exception)
|
2022-03-04 12:01:43 -08:00
|
|
|
|
{
|
2022-07-27 10:10:01 -07:00
|
|
|
|
Thread.Sleep(200);
|
|
|
|
|
DoesToolExist(path);
|
2022-03-04 12:01:43 -08:00
|
|
|
|
}
|
2022-07-27 10:10:01 -07:00
|
|
|
|
|
2022-03-04 12:01:43 -08:00
|
|
|
|
return true;
|
2020-04-03 00:49:48 +02: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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|