예제 #1
0
    private void Button1_Click(object sender, EventArgs e)
    {
        if (this.TextBox2.Text.Length <= 1)
        {
            this.TextBox2.Text = Application.StartupPath;
        }
        string text = this.TextBox2.Text;
        string str  = "Unity.exe";

        try
        {
            Directory.SetCurrentDirectory(text);
        }
        catch (Exception expr_3D)
        {
            ProjectData.SetProjectError(expr_3D);
            Exception ex = expr_3D;
            Interaction.MsgBox(ex.Message, MsgBoxStyle.Critical, null);
            ProjectData.ClearProjectError();
            return;
        }
        if (!File.Exists(text + "/" + str))
        {
            Interaction.MsgBox("Application not found!\r\nYou need to specify the destination folder or copy the \"patch file\" in directory with application.", MsgBoxStyle.Critical, null);
        }
        else
        {
            Process[] processesByName = Process.GetProcessesByName("unity");
            if (processesByName.Length > 0)
            {
                Interaction.MsgBox("Need to close application first.", MsgBoxStyle.Critical, null);
            }
            else
            {
                string  se      = "CC 55 8B EC 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??";
                string  rep     = "CC B0 01 C3 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??";
                string  se2     = "CC 40 57 48 83 EC 30 80 79 ?? ?? 48 8B F9 75 ??";
                string  rep2    = "CC B0 01 C3 90 90 90 80 79 ?? ?? 48 8B F9 75 ??";
                Patcher patcher = new Patcher()
                {
                    fullPathToFile = text + "/" + str
                };
                this.DissableUi();
                patcher.msg = true;
                if (patcher.AddString(se, rep))
                {
                    if (patcher.Patch())
                    {
                        this.EnableUi();
                        if (patcher.msg && patcher.CurState != null)
                        {
                            Interaction.MsgBox(patcher.CurState.message, (MsgBoxStyle)patcher.CurState.errorLevel, null);
                        }
                        if (this.ComboBox1.SelectedIndex > 0)
                        {
                            this.Wrlc4x1(text, true, this.ComboBox1.SelectedIndex);
                        }
                        else
                        {
                            this.Wrlc4x1(text, true, this.ComboBox1.SelectedIndex);
                        }
                        return;
                    }
                    if (this.ComboBox1.SelectedIndex > 0)
                    {
                        patcher.patterns.Clear();
                        if (patcher.AddString(se2, rep2) && patcher.Patch())
                        {
                            this.EnableUi();
                            if (patcher.msg && patcher.CurState != null)
                            {
                                Interaction.MsgBox(patcher.CurState.message, (MsgBoxStyle)patcher.CurState.errorLevel, null);
                            }
                            if (this.ComboBox1.SelectedIndex > 0)
                            {
                                this.Wrlc4x1(text, true, this.ComboBox1.SelectedIndex);
                            }
                            else
                            {
                                this.Wrlc4x1(text, true, this.ComboBox1.SelectedIndex);
                            }
                            return;
                        }
                    }
                }
                this.EnableUi();
                if (patcher.CurState != null)
                {
                    Interaction.MsgBox(patcher.CurState.message, (MsgBoxStyle)patcher.CurState.errorLevel, null);
                }
                else
                {
                    Interaction.MsgBox("Inside error!!", MsgBoxStyle.OkOnly, null);
                }
            }
        }
    }