public bool ProcessFilter(Process p) { try { var hdl = MemoryReader.OpenProcess(MemoryReader.ProcessAccessFlags.QueryLimitedInformation, false, p.Id); if (hdl == IntPtr.Zero) { return(false); } if (!Environment.Is64BitOperatingSystem) { return(true); } IsWow64Process(hdl, out bool rv); MemoryReader.CloseHandle(hdl); return(rv == !Environment.Is64BitProcess); } catch (Win32Exception) { return(false); } catch (InvalidOperationException) { return(false); } }
private void bt_load_table_Click(object sender, System.EventArgs e) { if (_mMemory != null) { _mMemory.CloseHandle(); } string file = "Test.CT"; _mMemoryList = new CheatEngineReader(); _mMemoryList.Read(file); lbl_table.Text = "Table:" + file; // Update UI. _mTable.Items.Clear(); // Search for the exe Process[] p = Process.GetProcessesByName(_mMemoryList.ProcessExe.Substring(0, _mMemoryList.ProcessExe.Length - 4)); if (p.Length == 1) { _mProcess = p[0]; _mMemory = new MemoryReader(); _mMemory.ReadProcess = p[0]; _mMemory.OpenProcess(); lbl_exe.Text = "PID:" + p[0].Id + "\r\n[" + p[0].ProcessName + "]"; } else if (p.Length == 0) { lbl_exe.Text = "Failed"; MessageBox.Show("Please load only if the process is already running."); // TODO: Wait for process. return; } else { lbl_exe.Text = "Failed"; MessageBox.Show("Found multiple exe's running! Cannot figure out what to-do."); //TODO: Add dialog. return; } IntPtr base_addr = p[0].MainModule.BaseAddress; for (int i = 0; i < _mMemoryList.Channels.Count; i++) { _mMemoryList.Channels[i].UI_ID = i; _mMemoryList.Channels[i].Address = new IntPtr(_mMemoryList.Channels[i].Address.ToInt32() + base_addr.ToInt32()); MemoryChannel ch = _mMemoryList.Channels[i]; _mTable.Items.Add(new ListViewItem(new string[5] { ch.ID.ToString(), ch.Name, "0x" + String.Format("{0,10:X}", ch.Address.ToInt32()), ch.TypeToString(), "0.000" })); } _mGrabber = new Grabber(_mMemoryList, _mMemory); _mGrabber.Done += new Signal(_mGrabber_Done); }
private void bt_load_table_Click(object sender, System.EventArgs e) { if (_mMemory != null) { _mMemory.CloseHandle(); } string file = "Test.CT"; _mMemoryList = new CheatEngineReader(); _mMemoryList.Read(file); lbl_table.Text = "Table:" + file; // Update UI. _mTable.Items.Clear(); // Search for the exe Process[] p = Process.GetProcessesByName(_mMemoryList.ProcessExe.Substring(0, _mMemoryList.ProcessExe.Length - 4)); if (p.Length == 1) { _mProcess = p[0]; _mMemory = new MemoryReader(); _mMemory.ReadProcess = p[0]; _mMemory.OpenProcess(); lbl_exe.Text = "PID:" + p[0].Id + "\r\n[" + p[0].ProcessName + "]"; } else if (p.Length == 0) { lbl_exe.Text = "Failed"; MessageBox.Show("Please load only if the process is already running."); // TODO: Wait for process. return; } else { lbl_exe.Text = "Failed"; MessageBox.Show("Found multiple exe's running! Cannot figure out what to-do."); //TODO: Add dialog. return; } IntPtr base_addr = p[0].MainModule.BaseAddress; for (int i = 0; i < _mMemoryList.Channels.Count; i++) { _mMemoryList.Channels[i].UI_ID = i; _mMemoryList.Channels[i].Address = new IntPtr(_mMemoryList.Channels[i].Address.ToInt32() + base_addr.ToInt32()); MemoryChannel ch = _mMemoryList.Channels[i]; _mTable.Items.Add(new ListViewItem(new string[5] { ch.ID.ToString(), ch.Name, "0x"+String.Format("{0,10:X}", ch.Address.ToInt32()), ch.TypeToString(), "0.000" })); } _mGrabber = new Grabber(_mMemoryList, _mMemory); _mGrabber.Done += new Signal(_mGrabber_Done); }
private void ProcessCombo_OnSelectionChanged(object sender, SelectionChangedEventArgs e) { try { Window.Title = ((TibiaProc)processCombo.SelectedItem).WindowTitle.Replace("Tibia", "Bot"); MemoryReader.Initialize(); MemoryReader.OpenProcess(((TibiaProc)processCombo.SelectedItem).Process); } catch (Exception ex) { // var alert = new Alarm(); // alert.IsEnabled = true; // alert.Play(); // // MessageBoxResult result = MessageBox.Show($"{ex}", "Something happened", MessageBoxButton.OK, MessageBoxImage.Exclamation); // if (result == MessageBoxResult.OK) // { // alert.Stop(); // alert.IsEnabled = false; // } Console.WriteLine(ex); //throw; } try { var settings = SettingsManager.Instance; settings.Deserialize($"{((TibiaProc)processCombo.SelectedItem).WindowTitle}.xml", ref settings); settings.ApplyCustomSettings(); //var list = new List<HealControl>(); HealControls = new List <HealControl>(); icHeal.Children.Clear(); foreach (var settingsHealerSetting in settings.HealerSettings) { var heal = new HealControl(); heal.Healresfrom.Text = settingsHealerSetting.From; heal.Healresto.Text = settingsHealerSetting.To; heal.Healreqmana.Text = settingsHealerSetting.RequiredMana; //heal.IsPercent = settingsHealerSetting.IsPercent; //heal.ResourceType = settingsHealerSetting.Type; heal.Keysres.SelectedValue = settingsHealerSetting.Key; heal.slValue.Value = settingsHealerSetting.Priority; if (settingsHealerSetting.IsPercent == true) { heal.ProcRadio.IsChecked = true; } else if (settingsHealerSetting.IsPercent == false) { heal.FlatRadio.IsChecked = true; } if (settingsHealerSetting.Type == Healer.ResourceType.Health) { heal.HealthRadio.IsChecked = true; } else if (settingsHealerSetting.Type == Healer.ResourceType.Mana) { heal.ManaRadio.IsChecked = true; } HealControls.Add(heal); icHeal.Children.Add(heal); } } catch (Exception exception) { Console.WriteLine(exception); //throw; } }