diff --git a/README.md b/README.md index 523724f..c12d7d5 100644 --- a/README.md +++ b/README.md @@ -3,27 +3,28 @@ This tool automates much of the installation of h-encore. [![Project Status: Active – The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/latest/active.svg)](http://www.repostatus.org/#active) -## Features -- Automatically download required tools and files -- Use already downloaded files, not requiring another download -- Guide users through the installation +## About +This tool automates the install process of thefl0w's h-encore exploit for PS Vita, at least everything that can be done on the PC. +Since I can't code in C or C++, I was unable to use OpenCMA as a backend, so I used QCMA. It's automatically downloaded and does not require to be installed. +Configuration of QCMA is done via registry edits. The application also detects existing QCMA installations and restores the original settings after the exploit was installed. + +**Attention: This tool only supports connection of the PSVita using Wi-Fi!** ## Usage Download from the releases section, extract it and run the executable. -It's heavily based on TheFlow's own usage guide, just automating as many things as possible. Therefore it should work on all vita systems. This tool was tested on a PSVita 1000. ## Building -Visual Studio 2017 Community Edition was tested. Might work in other IDEs as well. +Build using Visual Studio 2017, this was tested. Other C# IDEs might work as well. ## Todo -- Automate entering the AID +- Translations - Mac/Linux Compatibilty -- full Automation without needing qcma - Fix bugs (you tell me!) ## Thanks - thefl0w for h-encore and all their work in the vita scene - yifanlu for psvimgtools and all their other work in the vita scene - - mmozeiko for psvimgtools - - noahc3 for auto-h-encore and therefore showing me how to make ZUGABE better. + - mmozeiko for pkg2zip + - noahc3 for auto-h-encore + - xxyz for pngshot - All the contributors of the vita hacking scene diff --git a/h-encore-auto/AutoMode.xaml b/h-encore-auto/AutoMode.xaml index b62362f..54627cc 100644 --- a/h-encore-auto/AutoMode.xaml +++ b/h-encore-auto/AutoMode.xaml @@ -5,7 +5,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:local="clr-namespace:h_encore_auto" mc:Ignorable="d" - Title="ZUGABE" Height="175.807" Width="512" ResizeMode="CanMinimize" WindowStyle="None"> + Title="ZUGABE" Height="175.807" Width="512" ResizeMode="NoResize" WindowStyle="None"> diff --git a/h-encore-auto/AutoMode.xaml.cs b/h-encore-auto/AutoMode.xaml.cs index 79446de..bdd592a 100644 --- a/h-encore-auto/AutoMode.xaml.cs +++ b/h-encore-auto/AutoMode.xaml.cs @@ -1,18 +1,8 @@ using System; -using System.Collections.Generic; using System.Diagnostics; using System.IO; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Imaging; -using System.Windows.Shapes; using System.Threading; namespace h_encore_auto @@ -29,13 +19,13 @@ namespace h_encore_auto if (File.Exists(Ref.tempDir + "keepfile")) { Ref.areFilesKept = true; + Util.keepFilesCleanup(); } else { Ref.areFilesKept = false; if (Directory.Exists(Ref.tempDir)) Util.DeleteDirectory(Ref.tempDir); - Directory.CreateDirectory(Ref.tempDir); } InitTimer(); @@ -43,6 +33,7 @@ namespace h_encore_auto private void buttonStart_Click(object sender, RoutedEventArgs e) { + Directory.CreateDirectory(Ref.tempDir); buttonStart.IsEnabled = false; buttonClose.IsEnabled = false; barWorking.Visibility = Visibility.Visible; @@ -50,7 +41,6 @@ namespace h_encore_auto new Thread(() => { Thread.CurrentThread.IsBackground = true; - /* run your code here */ Process[] pname = Process.GetProcessesByName("qcma"); if (pname.Length != 0) @@ -62,10 +52,6 @@ namespace h_encore_auto MessageBox.Show("QCMA was closed, since this application has to interact with it."); } - // 7ZIP Download and extraction - Util.dlFile(Ref.url7zr, "7zr.exe"); - Util.dlFile(Ref.url7za, "7z-extra.7z"); - Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); ProcessStartInfo startInfoOut = new ProcessStartInfo(); @@ -78,26 +64,33 @@ namespace h_encore_auto startInfoOut.FileName = "cmd.exe"; startInfoOut.WorkingDirectory = Ref.tempDir; - startInfo.Arguments = "/C 7zr.exe x 7z-extra.7z"; - process.StartInfo = startInfo; - process.Start(); - process.WaitForExit(); + if (Ref.areFilesKept == false) + { + // 7ZIP Download and extraction + Util.dlFile(Ref.url7zr, "7zr.exe"); + Util.dlFile(Ref.url7za, "7z-extra.7z"); - //Rest of the tool downloads - Util.dlFile(Ref.urlPsvimg, "psvimgtools.zip"); - Util.dlFile(Ref.urlPkg, "pkg2zip.zip"); - Util.dlFile(Ref.urlEnc, "h-encore.zip"); - Util.dlFile(Ref.urlEntry, "entryPoint.pkg"); - Util.dlFile(Ref.urlQcma, "qcma.zip"); - Util.dlFile(Ref.urlReg, "qcma.reg"); + startInfo.Arguments = "/C 7zr.exe x 7z-extra.7z"; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); - string text = File.ReadAllText(Ref.pathImportReg); - text = text.Replace("REPLACE", Ref.pathQcmaRes); - File.WriteAllText(Ref.pathImportReg, text); - text = text.Replace("\\", "/"); - File.WriteAllText(Ref.pathImportReg, text); - text = text.Replace("HKEY_CURRENT_USER/Software/codestation/qcma", @"HKEY_CURRENT_USER\Software\codestation\qcma"); - File.WriteAllText(Ref.pathImportReg, text); + //Rest of the tool downloads + Util.dlFile(Ref.urlPsvimg, "psvimgtools.zip"); + Util.dlFile(Ref.urlPkg, "pkg2zip.zip"); + Util.dlFile(Ref.urlEnc, "h-encore.zip"); + Util.dlFile(Ref.urlEntry, "entryPoint.pkg"); + Util.dlFile(Ref.urlQcma, "qcma.zip"); + Util.dlFile(Ref.urlReg, "qcma.reg"); + + string text = File.ReadAllText(Ref.pathImportReg); + text = text.Replace("REPLACE", Ref.pathQcmaRes); + File.WriteAllText(Ref.pathImportReg, text); + text = text.Replace("\\", "/"); + File.WriteAllText(Ref.pathImportReg, text); + text = text.Replace("HKEY_CURRENT_USER/Software/codestation/qcma", @"HKEY_CURRENT_USER\Software\codestation\qcma"); + File.WriteAllText(Ref.pathImportReg, text); + } startInfo.Arguments = "/C " + Ref.path7z + " x " + Ref.pathPsvimg; process.StartInfo = startInfo; @@ -126,15 +119,8 @@ namespace h_encore_auto process.Start(); process.WaitForExit(); - startInfo.Arguments = "/C xcopy /E /Y /I " + Ref.tempDir + @"app\PCSG90096\ " + Ref.tempDir + @"h-encore\app\ux0_temp_game_PCSG90096_app_PCSG90096\"; - process.StartInfo = startInfo; - process.Start(); - process.WaitForExit(); - - startInfo.Arguments = "/C xcopy /E /Y /I " + Ref.tempDir + @"app\PCSG90096\sce_sys\package\temp.bin " + Ref.tempDir + @"h-encore\license\ux0_temp_game_PCSG90096_license_app_PCSG90096\6488b73b912a753a492e2714e9b38bc7.rif*"; - process.StartInfo = startInfo; - process.Start(); - process.WaitForExit(); + Util.CopyDir(Ref.tempDir + "app\\PCSG90096\\", Ref.tempDir + "h-encore\\app\\ux0_temp_game_PCSG90096_app_PCSG90096\\",true); + File.Copy(Ref.tempDir + "app\\PCSG90096\\sce_sys\\package\\temp.bin", Ref.tempDir + @"h-encore\license\ux0_temp_game_PCSG90096_license_app_PCSG90096\6488b73b912a753a492e2714e9b38bc7.rif"); try { @@ -226,7 +212,9 @@ namespace h_encore_auto for (; ; ) { stage = 0; + Ref.isSecondGuide = false; guide.ShowDialog(); + Ref.isSecondGuide = true; if (Util.IsDirectoryEmpty(Ref.pathQcmaRes + "PSVita\\APP\\")) { @@ -255,20 +243,15 @@ namespace h_encore_auto startInfo.WorkingDirectory = Ref.tempDir + "h-encore"; Ref.shortAID = new DirectoryInfo(Directory.GetDirectories(Ref.pathQcmaRes + "PSVita\\APP\\")[0]).Name; - MessageBox.Show(Ref.shortAID); Ref.longAID = Util.GetEncKey(Ref.shortAID); - MessageBox.Show(Ref.longAID); startInfo.Arguments = "/C create.bat " + Ref.longAID; process.StartInfo = startInfo; process.Start(); process.WaitForExit(); - startInfo.Arguments = "/C xcopy /E /Y /I " + Ref.tempDir + @"h-encore\PCSG90096\ " + Ref.pathQcmaRes + "PSVita\\" + Ref.shortAID + "\\PCSG90096\\"; - process.StartInfo = startInfo; - process.Start(); - process.WaitForExit(); + Util.CopyDir(Ref.tempDir + "h-encore\\PCSG90096\\", Ref.pathQcmaRes + "PSVita\\APP\\" + Ref.shortAID + "\\PCSG90096\\", true); stage = 3; }).Start(); @@ -276,7 +259,6 @@ namespace h_encore_auto if (stage == 3) { stage = 0; - Ref.isSecondGuide = true; guide.ShowDialog(); MessageBox.Show("If not already done, wait until your Vita has copied over the exploit, then press OK."); diff --git a/h-encore-auto/Util.cs b/h-encore-auto/Util.cs index 2dd7ae2..dab67d8 100644 --- a/h-encore-auto/Util.cs +++ b/h-encore-auto/Util.cs @@ -95,7 +95,9 @@ namespace h_encore_auto if (Directory.Exists(Ref.tempDir)) { if (MessageBox.Show("Do you want to keep the downloaded files for future use?\nPressing no will wipe any leftover files of this application off your computer.", "Keep Files?", MessageBoxButton.YesNo) == MessageBoxResult.Yes) - File.Create(Ref.tempDir + "keepfile"); + { + keepFilesCleanup(); + } else DeleteDirectory(Ref.tempDir); } @@ -117,5 +119,74 @@ namespace h_encore_auto return ci.TwoLetterISOLanguageName; } + + public static void CopyDir(string sourceDirName, string destDirName, bool copySubDirs) + { + // Get the subdirectories for the specified directory. + DirectoryInfo dir = new DirectoryInfo(sourceDirName); + + if (!dir.Exists) + { + throw new DirectoryNotFoundException("Source directory does not exist or could not be found: " + sourceDirName); + } + + DirectoryInfo[] dirs = dir.GetDirectories(); + // If the destination directory doesn't exist, create it. + if (!Directory.Exists(destDirName)) + { + Directory.CreateDirectory(destDirName); + } + + // Get the files in the directory and copy them to the new location. + FileInfo[] files = dir.GetFiles(); + foreach (FileInfo file in files) + { + string temppath = Path.Combine(destDirName, file.Name); + file.CopyTo(temppath, false); + } + + // If copying subdirectories, copy them and their contents to new location. + if (copySubDirs) + { + foreach (DirectoryInfo subdir in dirs) + { + string temppath = Path.Combine(destDirName, subdir.Name); + CopyDir(subdir.FullName, temppath, copySubDirs); + } + } + } + public static void keepFilesCleanup() + { + if (!File.Exists(Ref.tempDir + "keepfile")) + { + File.Create(Ref.tempDir + "keepfile"); + } + + string backupTemp = Ref.tempDir + "keepfiles\\"; + Directory.CreateDirectory(backupTemp); + + foreach (string download in Ref.downloads) + { + File.Copy(Ref.tempDir + download, backupTemp + download); + } + + Util.DeleteDirectory(Ref.tempDir + "\\app"); + Util.DeleteDirectory(Ref.tempDir + "\\Far"); + Util.DeleteDirectory(Ref.tempDir + "\\h-encore"); + Util.DeleteDirectory(Ref.tempDir + "\\Qcma"); + Util.DeleteDirectory(Ref.tempDir + "\\QcmaRes"); + Util.DeleteDirectory(Ref.tempDir + "\\x64"); + + foreach (string file in Directory.GetFiles(Ref.tempDir)) + { + File.Delete(file); + } + + foreach (string download in Ref.downloads) + { + File.Copy(backupTemp + download, Ref.tempDir + download); + } + Util.DeleteDirectory(backupTemp); + } } } \ No newline at end of file diff --git a/h-encore-auto/VitaGuide.xaml.cs b/h-encore-auto/VitaGuide.xaml.cs index 7e6a26d..47f662f 100644 --- a/h-encore-auto/VitaGuide.xaml.cs +++ b/h-encore-auto/VitaGuide.xaml.cs @@ -1,16 +1,6 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using System.Windows; -using System.Windows.Controls; -using System.Windows.Data; -using System.Windows.Documents; -using System.Windows.Input; -using System.Windows.Media; using System.Windows.Media.Imaging; -using System.Windows.Shapes; namespace h_encore_auto { @@ -19,7 +9,7 @@ namespace h_encore_auto /// public partial class VitaGuide : Window { - int currImg = 1; + int currImg; string[] currText = lang.GuideText(Util.GetLang()); @@ -28,9 +18,9 @@ namespace h_encore_auto InitializeComponent(); if (Ref.isSecondGuide == true) - { currImg = 15; - } + else + currImg = 1; imgFrame.Source = new BitmapImage(new Uri("/img/" + currImg + ".png", UriKind.Relative)); textField.Text = currText[currImg - 1]; @@ -44,7 +34,7 @@ namespace h_encore_auto textField.Text = currText[currImg - 1]; buttonBck.IsEnabled = true; - if (currImg == 14 || currImg == 25) + if (currImg == 14 || currImg == 26) { buttonFwd.IsEnabled = false; buttonDone.Visibility = Visibility.Visible; diff --git a/h-encore-auto/h-encore-auto.csproj b/h-encore-auto/h-encore-auto.csproj index 6e8c970..4155c40 100644 --- a/h-encore-auto/h-encore-auto.csproj +++ b/h-encore-auto/h-encore-auto.csproj @@ -8,7 +8,7 @@ {9F8577B2-16A2-4147-B264-308B68679F78} WinExe h_encore_auto - h-encore-auto + ZUGABE v4.5.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} @@ -53,10 +53,10 @@ 4 false + + icon.ico + - - ..\packages\Essy.Tools.InputBox.1.0.0\lib\net20\InputBox.dll - @@ -164,6 +164,17 @@ + + + + + + + + + + + diff --git a/h-encore-auto/icon.ico b/h-encore-auto/icon.ico new file mode 100644 index 0000000..b93cb05 Binary files /dev/null and b/h-encore-auto/icon.ico differ diff --git a/h-encore-auto/img/20.png b/h-encore-auto/img/20.png new file mode 100644 index 0000000..7e57203 Binary files /dev/null and b/h-encore-auto/img/20.png differ diff --git a/h-encore-auto/img/21.png b/h-encore-auto/img/21.png new file mode 100644 index 0000000..e6371ad Binary files /dev/null and b/h-encore-auto/img/21.png differ diff --git a/h-encore-auto/img/22.png b/h-encore-auto/img/22.png new file mode 100644 index 0000000..da8d046 Binary files /dev/null and b/h-encore-auto/img/22.png differ diff --git a/h-encore-auto/img/23.png b/h-encore-auto/img/23.png new file mode 100644 index 0000000..fd84a77 Binary files /dev/null and b/h-encore-auto/img/23.png differ diff --git a/h-encore-auto/img/24.png b/h-encore-auto/img/24.png new file mode 100644 index 0000000..d74c69c Binary files /dev/null and b/h-encore-auto/img/24.png differ diff --git a/h-encore-auto/img/25.png b/h-encore-auto/img/25.png new file mode 100644 index 0000000..226d399 Binary files /dev/null and b/h-encore-auto/img/25.png differ diff --git a/h-encore-auto/img/icon.ico b/h-encore-auto/img/icon.ico new file mode 100644 index 0000000..b93cb05 Binary files /dev/null and b/h-encore-auto/img/icon.ico differ diff --git a/h-encore-auto/lang.cs b/h-encore-auto/lang.cs index a852402..58923be 100644 --- a/h-encore-auto/lang.cs +++ b/h-encore-auto/lang.cs @@ -1,10 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace h_encore_auto +namespace h_encore_auto { class lang { @@ -36,11 +30,12 @@ namespace h_encore_auto "3. Wait for it to connect.", "4. Select \"PC -> PS Vita System\"", "5. Select \"Applications\"", - "6", - "7", - "8", - "9", - "10", + "6. Select \"PS Vita\"", + "7. Tick \"h-encore\" and click \"copy\". Wait for it to complete and close Content Manager.", + "8. Start the new \"h-encore\" bubble.", + "9. Select \"Install HENkaku\"", + "10. Select \"Download VitaShell\"", + "11. Finally, exit.", "Done. Keep in mind that you have to launch h-encore every time you reboot the Vita. \nWhen launched, just press Exit again. This reapplies the exploit." }; } diff --git a/h-encore-auto/packages.config b/h-encore-auto/packages.config index e4f14b1..65fbff3 100644 --- a/h-encore-auto/packages.config +++ b/h-encore-auto/packages.config @@ -1,5 +1,4 @@  - \ No newline at end of file diff --git a/h-encore-auto/ref.cs b/h-encore-auto/ref.cs index f7a0838..1f55cae 100644 --- a/h-encore-auto/ref.cs +++ b/h-encore-auto/ref.cs @@ -34,6 +34,17 @@ namespace h_encore_auto "text\\01\\" }; + public static readonly string[] downloads = new string[] { + "7zr.exe", + "7z-extra.7z", + "entryPoint.pkg", + "h-encore.zip", + "pkg2zip.zip", + "psvimgtools.zip", + "qcma.reg", + "qcma.zip" + }; + public static bool isSecondGuide = false; public static bool isQcmaConfigFound = false;