From 8fc1739a344c5563f085eb256f22b1a276e40978 Mon Sep 17 00:00:00 2001 From: Jakob Date: Fri, 6 Jul 2018 00:17:40 +0200 Subject: [PATCH] working on auto mode --- download-resources/qcma.reg | Bin 0 -> 982 bytes h-encore-auto/AutoMode.xaml.cs | 100 +++++++++++++++++++++++++++++++++ h-encore-auto/ref.cs | 26 +++++---- 3 files changed, 114 insertions(+), 12 deletions(-) create mode 100644 download-resources/qcma.reg diff --git a/download-resources/qcma.reg b/download-resources/qcma.reg new file mode 100644 index 0000000000000000000000000000000000000000..c7bb6763dd440c0797267fc0f5a413cbf95eb8ba GIT binary patch literal 982 zcma)*OH0F05QWcL@IOd@fRBY6!G(&TXr;7P5fzC|qQSPQ#`^m4>UZun)`l)5gxoui zGv~}qzCO=YXslGFUR7yDU1hq%R_R$!ddISlx8PQCU(p%T&Msif^eL%vU9#WmpDSQckX$@J9SAJ>nT*xen+pP7|I= zoe*`embQ6aqoZT(P;*~voO>`e>jba4wKS#D@Lzd-Dx?A5eCqs(9_Y+}>N;jXbVB@J z1Z&RW;Erc%|0s?M-0dmWx>`kk0gpB|tB8E8#(HxsL%7Z2J);WiE%q#QdiN)`i98?a z`FjG+s)E|Z_|s6$Y)0_*X7u3YQ&hQF#RPvD;ymA>4#TcxdJEiA=5K^lTVaR1NA(kD z*36&pSwhFm!TaHj8Gst|Uf?;~(r4ICutbg@!B_sq7EEazc$n7+mW#F2)!eNdboZ;? pzh;jIF!Lsx+dP+uZI$uAnSE>SP0jOvob#J~+dz4aHKPyK{|!+#pY#9# literal 0 HcmV?d00001 diff --git a/h-encore-auto/AutoMode.xaml.cs b/h-encore-auto/AutoMode.xaml.cs index 7cf5e9f..04a82ab 100644 --- a/h-encore-auto/AutoMode.xaml.cs +++ b/h-encore-auto/AutoMode.xaml.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -35,6 +36,11 @@ namespace h_encore_auto string pathPkg = Ref.tempDir + "pkg2zip.zip"; string pathEnc = Ref.tempDir + "h-encore.zip"; string pathEntry = Ref.tempDir + "entryPoint.pkg"; + string pathQcma = Ref.tempDir + "qcma.zip"; + string pathQcmaExtracted = Ref.tempDir + "Qcma\\"; + string pathBackupReg = Ref.tempDir + "backup.reg"; + string pathImportReg = Ref.tempDir + "qcma.reg"; + string pathQcmaRes = Ref.tempDir + "QcmaRes\\"; private void Window_Closed(object sender, EventArgs e) { @@ -50,6 +56,8 @@ namespace h_encore_auto Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); + ProcessStartInfo startInfoOut = new ProcessStartInfo(); + startInfo.WindowStyle = ProcessWindowStyle.Hidden; startInfo.FileName = "cmd.exe"; startInfo.WorkingDirectory = Ref.tempDir; @@ -64,6 +72,98 @@ namespace h_encore_auto 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(pathImportReg); + text = text.Replace("REPLACE", pathQcmaRes); + File.WriteAllText(pathImportReg, text); + + startInfo.Arguments = "/C " + path7z + " x " + pathPsvimg; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + + startInfo.Arguments = "/C " + path7z + " x " + pathPkg; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + + startInfo.Arguments = "/C " + path7z + " x " + pathEnc; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + + startInfo.Arguments = "/C " + path7z + " x " + pathQcma; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + + startInfo.Arguments = "/C " + Ref.tempDir + "pkg2zip.exe -x " + pathEntry; + process.StartInfo = startInfo; + 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(); + + try + { + string path = Ref.tempDir + "app\\PCSG90096\\resource\\"; + foreach (string k in Ref.trims) + { + Util.DeleteDirectory(path + k); + } + } + catch (Exception ex) + { + MessageBox.Show("Exception: " + ex.Message + "\nYou should tell the developer in a github issue. Include a screenshot if possible!"); + return; + } + + bool qcmaConfigFound = false; + + startInfoOut.RedirectStandardOutput = true; + startInfoOut.UseShellExecute = false; + startInfoOut.Arguments = @"/C reg query HKEY_CURRENT_USER\Software\codestation\qcma & echo 0"; + process.StartInfo = startInfoOut; + process.Start(); + string stdout = process.StandardOutput.ReadToEnd(); + process.WaitForExit(); + + if (stdout == "0") + { + qcmaConfigFound = false; + + startInfo.Arguments = @"/C reg import " + pathImportReg; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + } + + else + { + qcmaConfigFound = true; + + startInfo.Arguments = @"/C reg export HKEY_CURRENT_USER\Software\codestation\qcma " + pathBackupReg; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + + startInfo.Arguments = @" / C reg import " + pathImportReg; + process.StartInfo = startInfo; + process.Start(); + process.WaitForExit(); + } + + } } } diff --git a/h-encore-auto/ref.cs b/h-encore-auto/ref.cs index 37b205e..65197fd 100644 --- a/h-encore-auto/ref.cs +++ b/h-encore-auto/ref.cs @@ -11,21 +11,23 @@ namespace h_encore_auto public static readonly string urlEntry = "http://ares.dl.playstation.net/cdn/JP0741/PCSG90096_00/xGMrXOkORxWRyqzLMihZPqsXAbAXLzvAdJFqtPJLAZTgOcqJobxQAhLNbgiFydVlcmVOrpZKklOYxizQCRpiLfjeROuWivGXfwgkq.pkg"; public static readonly string url7zr = "https://www.7-zip.org/a/7zr.exe"; public static readonly string url7za = "https://www.7-zip.org/a/7z1805-extra.7z"; + public static readonly string urlQcma = "https://github.com/fyr77/ZUGABE/blob/master/download-resources/Qcma.zip?raw=true"; + public static readonly string urlReg = ""; public static readonly string tempDir = Path.GetTempPath() + @"encore_temp\"; - public static readonly string[] trims = new string[] { - "movie\\", - "image\\bg\\", - "image\\ev\\", - "image\\icon\\", - "image\\stitle\\", - "image\\tachie\\", - "sound\\bgm\\", - "sound\\se\\", - "sound\\sec\\", - "sound\\voice\\", - "text\\01\\" + public static readonly string[] trims = new string[] { + "movie\\", + "image\\bg\\", + "image\\ev\\", + "image\\icon\\", + "image\\stitle\\", + "image\\tachie\\", + "sound\\bgm\\", + "sound\\se\\", + "sound\\sec\\", + "sound\\voice\\", + "text\\01\\" }; } }