finished automation

This commit is contained in:
Jakob 2018-07-06 23:05:42 +02:00
parent a26960cea1
commit 4b3163c80f
17 changed files with 153 additions and 93 deletions

View file

@ -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.");