Пример #1
0
        private void btnCompile_Click(object sender, EventArgs e)
        {
            HackFile hackFile = new HackFile(fileName);

            if (!hackFile.CheckFile())
            {
                MessageBox.Show("The current .zip isn't valid!", "ZIP isn't valid");
                return;
            }

            if (isCompiling)
            {
                MessageBox.Show("Still compiling, please wait.", "Still Compiling!");
                return;
            }

            isCompiling = true;

            for (int i = 0; (int)i < num_Copies.Value; i++)
            {
                compileThread = new Thread(new ParameterizedThreadStart(this.Compile));
                compileThread.Start(hackFile);
            }
        }
Пример #2
0
        private void Compile(object data)
        {
            int progress = 4;

            string outputName = Junk.RandomString(25) + ".exe";

            SetProgressBar(0, progress);
            SetStatus("Unzipping..");
            HackFile hackFile  = (HackFile)data;
            string   directory = string.Concat(Path.GetFileNameWithoutExtension(fileName), "/");
            char     encKey    = Junk.RandomString(1).ToCharArray()[0];

            hackFile.Unzip(directory, encKey);
            StringEnc.SetKey(encKey);

            SetProgressBar(1, progress);
            SetStatus("Randomizing and Encrypting..");

            string str1 = string.Concat(Path.GetFileNameWithoutExtension(fileName), "_R/");

            hackFile.RandomizeAllFiles(directory, str1);
            SetProgressBar(2, progress);

            SetStatus("Compiling..");
            string str2 = string.Concat(Path.GetDirectoryName(txtCompilerPath.Text), "\\");

            ProcessStartInfo processStartInfo = new ProcessStartInfo()
            {
                FileName = "cmd.exe"
            };

            string str3 = "/C ";

            str3 = string.Concat(str3, "cd ", str1, "&");
            str3 = string.Concat(str3, "\"", str2, "vcvars32.bat\"&");
            string str4 = str3;

            string[] strArrays = new string[] { str4, "\"", str2, "cl.exe\" ", txtCompilerArgs.Text };

            str3 = string.Concat(strArrays);
            if (!chkboxDebug.Checked)
            {
                processStartInfo.UseShellExecute       = false;
                processStartInfo.RedirectStandardInput = true;
                processStartInfo.WindowStyle           = ProcessWindowStyle.Hidden;
                processStartInfo.CreateNoWindow        = true;
            }
            else
            {
                str3 = string.Concat(str3, "&pause");
            }

            processStartInfo.Arguments = str3;
            // MessageBox.Show(str3);
            Process.Start(processStartInfo).WaitForExit();
            SetProgressBar(3, progress);
            SetStatus("Finishing up..");

            if (File.Exists(outputName))
            {
                File.Delete(outputName);
            }

            bool flag = false;

            if (File.Exists(string.Concat(str1, outEXEName)))
            {
                File.Move(string.Concat(str1, outEXEName), outputName);
                flag = true;
            }

            if (chkBoxDeleteFolders.Checked)
            {
                Directory.Delete(directory, true);
                Directory.Delete(str1, true);
            }

            SetProgressBar(4, progress);
            SetStatus("Done with " + safeFileName);


            if (!flag)
            {
                if (chkBox_PromptMsg.Checked)
                {
                    MessageBox.Show("Something went wrong when compiling the randomized source!", "Error");
                }
            }
            else
            {
                if (chkBox_PromptMsg.Checked)
                {
                    MessageBox.Show(string.Concat("File saved as: ", outputName), "Compiling has been completed.");
                }

                if (num_Copies.Value == 1)
                {
                    if (chkBox_PromptMsg.Checked)
                    {
                        DialogResult msgBox = MessageBox.Show("Would you like to run this right now?", "Question", MessageBoxButtons.YesNo);

                        if (msgBox == System.Windows.Forms.DialogResult.Yes)
                        {
                            processStartInfo = new ProcessStartInfo()
                            {
                                FileName = outputName
                            };

                            Process.Start(processStartInfo).WaitForExit();
                        }
                    }
                }
            }

            isCompiling = false;
        }