private void button2_Click(object sender, EventArgs e) { if (this.textBox1.Text.Length < 3) { this.textBox1.Text = Application.StartupPath; } string text = this.textBox1.Text; try { if (Process.GetProcessesByName("unity").Length != 0) { throw new Exception("Need to close application first."); } } catch (Exception arg_49_0) { MessageBox.Show(arg_49_0.Message, string.Empty, MessageBoxButtons.OK, MessageBoxIcon.Hand); return; } File.Copy(text + "/Unity.exe", text + "/Unity.exe.bak", true); NLogger.Clear(); string se = ""; string rep = ""; string se2 = ""; string rep2 = ""; if (this.patchAs < 530) { se = "CC 55 8B EC 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; rep = "CC B0 01 C3 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; se2 = "CC 40 57 48 83 EC 30 80 79 ?? ?? 48 8B F9 75 ??"; rep2 = "CC B0 01 C3 90 90 90 80 79 ?? ?? 48 8B F9 75 ??"; } if (this.patchAs >= 530 && this.patchAs < 20172) { se = "CC 55 8B EC 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; rep = "CC B0 01 C3 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; se2 = "CC 40 57 48 83 EC 30 80 79 ?? ?? 48 8B F9 75 ??"; rep2 = "CC B0 01 C3 90 90 90 80 79 ?? ?? 48 8B F9 75 ??"; } if (this.patchAs >= 20172) { se = "CC 55 8B EC 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; rep = "CC B0 01 C3 83 EC ?? 53 56 8B F1 80 7E ?? ?? 57 75 ??"; se2 = "CC 48 89 5C 24 10 48 89 6C 24 18 56 41 54 41 55 ?? 83 EC 30 ?? 8B E9"; rep2 = "CC B0 01 C3 90 90 48 89 6C 24 18 56 41 54 41 55 ?? 83 EC 30 ?? 8B E9"; } Patcher patcher = new Patcher(text + "/Unity.exe"); if (patcher.AddString(se, rep, 1u, 0u)) { if (patcher.Patch()) { NLogger.LastMessage(); this.WriteLicenseToFile(text, true, this.patchAs); return; } if (this.patchAs >= 500) { patcher.Patterns.Clear(); if (patcher.AddString(se2, rep2, 1u, 0u) && patcher.Patch()) { NLogger.LastMessage(); this.WriteLicenseToFile(text, true, this.patchAs); return; } } } NLogger.LastMessage(); }
public bool Patch() { if (this.Patterns == null) { NLogger.Error("ArgumentNullException: patterns."); return(false); } List <Patcher.Pattern> arg_39_0 = this.Patterns; Predicate <Patcher.Pattern> arg_39_1; arg_39_1 = Patcher.PatcherData.PatcherDataPredicate; if (arg_39_1 == null) { Patcher.PatcherData.PatcherDataPredicate = new Predicate <Patcher.Pattern>(Patcher.PatcherData.Instance.Patch); arg_39_1 = Patcher.PatcherData.PatcherDataPredicate; } arg_39_0.RemoveAll(arg_39_1); if (this.Patterns.Count == 0) { NLogger.Error("Collection is empty: patterns."); return(false); } uint num = 0u; uint num2 = 0u; bool flag = false; try { this._fs = this.CreateStream(this.FileName); foreach (Patcher.Pattern current in this.Patterns) { Patcher.MainPattern pt = this.FindAllPatterns(current); if (pt.SuccessfullyFound > 0) { if (this.ReplaceAllPatterns(pt)) { flag = true; } if (pt.Success) { num2 += 1u; } else { num2 += 1u; num += 1u; } } else { num += 1u; } } } catch (Exception ex) { if (this._fs != null) { this._fs.Dispose(); this._fs = null; } NLogger.Error(string.Format("{0}: {1}", ex.GetType(), ex.Message)); return(false); } if (this._fs != null) { this._fs.Close(); this._fs = null; } if (flag) { if (num > 0u && num2 > 0u) { NLogger.Debug(this._succesMessages[2]); this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[2]); return(true); } if (num == 0u && num2 > 0u) { NLogger.Debug(this._succesMessages[1]); this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[1]); return(true); } this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[0]); NLogger.Debug(this._succesMessages[0]); } else { if (num > 0u && num2 > 0u) { this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[4]); NLogger.Debug(this._succesMessages[4]); return(true); } if (num == 0u && num2 > 0u) { this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[3]); NLogger.Debug(this._succesMessages[3]); return(true); } this.CurrentState = new Patcher.PatcherState(flag, num2, num, this._succesMessages[0]); NLogger.Debug(this._succesMessages[0]); } return(false); }