private void settingsview_OnSettingsChanged(HookSettingsControl obj) { applybutton.Enabled = true; }
protected override async void OnLoad(EventArgs e) { base.OnLoad(e); methoddef = MainForm.GetMethod(Hook.AssemblyName, Hook.TypeName, Hook.Signature); hooktypes = new List <Type>(); int selindex = 0; int i = 0; foreach (var hooktype in Hook.GetHookTypes()) { string typename = hooktype.GetCustomAttribute <HookType>().Name; hooktypedropdown.Items.Add(typename); hooktypes.Add(hooktype); if (typename == Hook.HookTypeName) { selindex = i; } i++; } var hooks = MainForm.CurrentProject.GetManifest(Hook.AssemblyName).Hooks; var baseHooks = (from hook in hooks where hook.BaseHook != null select hook.BaseHook).ToList(); basehookdropdown.Items.Add(""); int selindex2 = 0; i = 1; foreach (var hook in hooks) { if (hook.BaseHook == Hook) { clonebutton.Enabled = false; } if (hook != Hook.BaseHook && baseHooks.Contains(hook)) { continue; } basehookdropdown.Items.Add(hook.Name); if (hook == Hook.BaseHook) { selindex2 = i; } i++; } assemblytextbox.Text = Hook.AssemblyName; typenametextbox.Text = Hook.TypeName; if (methoddef != null) { methodnametextbox.Text = Hook.Signature.ToString(); } else { methodnametextbox.Text = Hook.Signature + " (METHOD MISSING)"; } nametextbox.Text = Hook.Name; hooknametextbox.Text = Hook.HookName; ignoretypechange = true; hooktypedropdown.SelectedIndex = selindex; basehookdropdown.SelectedIndex = selindex2; ignoretypechange = false; applybutton.Enabled = false; if (Hook.Flagged) { flagbutton.Enabled = false; unflagbutton.Enabled = true; unflagbutton.Focus(); } else { flagbutton.Enabled = true; unflagbutton.Enabled = false; flagbutton.Focus(); } HookSettingsControl settingsview = Hook.CreateSettingsView(); if (settingsview == null) { Label tmp = new Label(); tmp.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; tmp.AutoSize = false; tmp.Text = "No settings."; tmp.Dock = DockStyle.Fill; hooksettingstab.Controls.Add(tmp); } else { settingsview.Dock = DockStyle.Fill; settingsview.OnSettingsChanged += settingsview_OnSettingsChanged; hooksettingstab.Controls.Add(settingsview); } if (methoddef == null) { Label missinglabel1 = new Label(); missinglabel1.Dock = DockStyle.Fill; missinglabel1.AutoSize = false; missinglabel1.Text = "METHOD MISSING"; missinglabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; beforetab.Controls.Add(missinglabel1); Label missinglabel2 = new Label(); missinglabel2.Dock = DockStyle.Fill; missinglabel2.AutoSize = false; missinglabel2.Text = "METHOD MISSING"; missinglabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; aftertab.Controls.Add(missinglabel2); return; } var weaver = new ILWeaver(methoddef.Body) { Module = methoddef.Module }; Hook.PreparePatch(methoddef, weaver, MainForm.OxideAssembly); msilbefore = new TextEditorControl { Dock = DockStyle.Fill, Text = weaver.ToString() }; codebefore = new TextEditorControl { Dock = DockStyle.Fill, Text = await Decompiler.GetSourceCode(methoddef, weaver), Document = { HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("C#") } }; Hook.ApplyPatch(methoddef, weaver, MainForm.OxideAssembly); msilafter = new TextEditorControl { Dock = DockStyle.Fill, Text = weaver.ToString() }; codeafter = new TextEditorControl { Dock = DockStyle.Fill, Text = await Decompiler.GetSourceCode(methoddef, weaver), Document = { HighlightingStrategy = HighlightingManager.Manager.FindHighlighter("C#") } }; beforetab.Controls.Add(msilbefore); aftertab.Controls.Add(msilafter); codebeforetab.Controls.Add(codebefore); codeaftertab.Controls.Add(codeafter); }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); methoddef = MainForm.GetMethod(Hook.AssemblyName, Hook.TypeName, Hook.Signature); hooktypes = new List <Type>(); int selindex = 0; int i = 0; foreach (var hooktype in Hook.GetHookTypes()) { string typename = hooktype.GetCustomAttribute <HookType>().Name; hooktypedropdown.Items.Add(typename); hooktypes.Add(hooktype); if (typename == Hook.HookTypeName) { selindex = i; } i++; } assemblytextbox.Text = Hook.AssemblyName; typenametextbox.Text = Hook.TypeName; if (methoddef != null) { methodnametextbox.Text = Hook.Signature.ToString(); } else { methodnametextbox.Text = Hook.Signature.ToString() + " (METHOD MISSING)"; } nametextbox.Text = Hook.Name; hooknametextbox.Text = Hook.HookName; ignoretypechange = true; hooktypedropdown.SelectedIndex = selindex; ignoretypechange = false; applybutton.Enabled = false; if (Hook.Flagged) { flagbutton.Enabled = false; unflagbutton.Enabled = true; unflagbutton.Focus(); } else { flagbutton.Enabled = true; unflagbutton.Enabled = false; flagbutton.Focus(); } HookSettingsControl settingsview = Hook.CreateSettingsView(); if (settingsview == null) { Label tmp = new Label(); tmp.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; tmp.AutoSize = false; tmp.Text = "No settings."; tmp.Dock = DockStyle.Fill; hooksettingstab.Controls.Add(tmp); } else { settingsview.Dock = DockStyle.Fill; settingsview.OnSettingsChanged += settingsview_OnSettingsChanged; hooksettingstab.Controls.Add(settingsview); } if (methoddef == null) { Label missinglabel1 = new Label(); missinglabel1.Dock = DockStyle.Fill; missinglabel1.AutoSize = false; missinglabel1.Text = "METHOD MISSING"; missinglabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; beforetab.Controls.Add(missinglabel1); Label missinglabel2 = new Label(); missinglabel2.Dock = DockStyle.Fill; missinglabel2.AutoSize = false; missinglabel2.Text = "METHOD MISSING"; missinglabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; aftertab.Controls.Add(missinglabel2); return; } ILWeaver weaver = new ILWeaver(methoddef.Body); weaver.Module = methoddef.Module; msilbefore = new TextEditorControl(); msilbefore.Dock = DockStyle.Fill; msilbefore.Text = weaver.ToString(); beforetab.Controls.Add(msilbefore); Hook.ApplyPatch(methoddef, weaver, MainForm.OxideAssembly); msilafter = new TextEditorControl(); msilafter.Dock = DockStyle.Fill; msilafter.Text = weaver.ToString(); aftertab.Controls.Add(msilafter); }