What i need is when process is selected from combo box that reads memory from selected process.
When i start bot and connect to game, it sets memory from first process found with process name "Game.exe". Since there is multiple processes "Game.exe" i want to read memory from selected, but it keeps reading only from first that he found.
I think problem with this is because when you set KDMemory to get values it accept process name in class, but since all processes have same name it takes first one.
Is it possible to read memory from PID (process id) or there is other way ?
Just to mention, process is 64 bit.
Code:
public partial class Form1 : Form
{
Process[] process;
static string processName = "Game.exe";
static string moduleName = processName;
static int mobHealth;
public Form1()
{
InitializeComponent();
}
private void btnConnect_Click(object sender, EventArgs e)
{
Process[] proc = Process.GetProcessesByName("game");
if (proc.Length != 0)
{
process = proc;
comboProcessList.Items.Clear();
for (int i = 0; i < proc.Length; i++)
{
comboProcessList.Items.Add("Game: " + (i + 1).ToString()); // text is jsut for visual display
}
comboProcessList.SelectedIndex = 0;
}
}
private void comboProcessList_SelectedIndexChanged(object sender, EventArgs e)
{
if (comboProcessList.SelectedIndex != -1)
{
process = null;
Process[] proc = Process.GetProcessesByName("game");
if (proc.Length != 0)
{
process = proc;
SetForegroundWindow(process[comboProcessList.SelectedIndex].MainWindowHandle);
ShowWindow(process[comboProcessList.SelectedIndex].MainWindowHandle, SW_RESTORE);
}
}
}
private void ReadMobHealth()
{
try
{
var staticOffset = Entities.mobStaticOffset;
var offsetsValue = Entities.mobHealthOffetsValues;
var memoryDataValue = new KDMemory(processName, moduleName, staticOffset, offsetsValue, WINAPI.ProcessAccessRights.PROCESS_VM_READ);
foreach (var integer in memoryDataValue.GetInt32())
{
mobHealth = integer;
}
}
catch
{
Console.WriteLine("Error accessing target health");
}
}
}