private void DllAddButton_Click(object sender, EventArgs e) { try { if (openFileDialog.ShowDialog() == DialogResult.OK) { IntPtr hModule = Kernel32.LoadLibrary(openFileDialog.FileName); object[] newDll = { true, openFileDialog.SafeFileName, openFileDialog.FileName }; Config.AddRange(newDll); DllGridView.Rows.Add(newDll); DllGridView.Rows[DllGridView.Rows.Count - 1].Cells["DllFunctions"] = new DataGridViewComboBoxCell { DataSource = InjectHelper.GetExportFunctions(hModule) }; Kernel32.FreeLibrary(hModule); } } catch (Exception Ex) { if (MessageBox.Show(Ex.Message + "\nПерезапустить приложение?", "Trion Injector - Ошибка", MessageBoxButtons.YesNo, MessageBoxIcon.Error) == DialogResult.Yes) { Application.Restart(); } } }
public Menu() { InitializeComponent(); UpdateProcessButton_Click(null, null); ProcessList_Click(ProcessList, null); Config = new List <object>(); using (FileStream fileStream = new FileStream("config.xml", FileMode.OpenOrCreate, FileAccess.Read)) { if (fileStream.Length == 0) { return; } Config.AddRange((object[])new XmlSerializer(typeof(object[])).Deserialize(fileStream)); DllGridView.Rows.Add(Config.ToArray()); for (int index = 0; index < DllGridView.Rows.Count; index++) { if (!File.Exists((string)DllGridView.Rows[index].Cells["DllPath"].Value)) { DllGridView.Rows.RemoveAt(index); continue; } IntPtr hModule = Kernel32.LoadLibrary((string)DllGridView.Rows[index].Cells["DllPath"].Value); DllGridView.Rows[index].Cells["DllFunctions"] = new DataGridViewComboBoxCell { DataSource = InjectHelper.GetExportFunctions(hModule) }; Kernel32.FreeLibrary(hModule); } } }