private void Window_Injector_Loaded(object sender, RoutedEventArgs e) { foreach (Process process in Process.GetProcesses()) { ListBox_Process.Items.Add(new ProcessList() { PID = process.Id, PName = process.ProcessName, MWindowTitle = process.MainWindowTitle }); } InjectInfo = new InjectInfo(); }
private void Button_InjectGameProcess_Click(object sender, RoutedEventArgs e) { AudioUtil.ClickSound(); SaveBlcokWords(); var InjectInfo = new InjectInfo(); InjectInfo.DLLPath = FileUtil.Inject_Path + "BlcokMsg.dll"; if (string.IsNullOrEmpty(InjectInfo.DLLPath)) { MsgBoxUtil.Warning("发生异常,DLL路径为空"); return; } var process = Process.GetProcessesByName("GTA5")[0]; InjectInfo.PID = process.Id; InjectInfo.PName = process.ProcessName; InjectInfo.MWindowHandle = process.MainWindowHandle; foreach (ProcessModule module in Process.GetProcessById(InjectInfo.PID).Modules) { if (module.FileName == InjectInfo.DLLPath) { MsgBoxUtil.Warning("该DLL已经被注入过了,请勿重复注入"); return; } } try { BaseInjector.SetForegroundWindow(InjectInfo.MWindowHandle); BaseInjector.DLLInjector(InjectInfo.PID, InjectInfo.DLLPath); } catch (Exception ex) { MsgBoxUtil.Exception(ex); } }
static InjectInfo GetInjectInfoInternal(object[] attributes) { if (!attributes.Any()) { return null; } var info = new InjectInfo(); foreach (var attr in attributes) { if (attr.GetType() == typeof(InjectOptionalAttribute)) { info.Optional = true; } else if (attr.GetType() == typeof(InjectNamedAttribute)) { var namedAttr = (InjectNamedAttribute)attr; info.Name = namedAttr.Name; } } return info; }