I need to get the modules from a process so i can get it is baseAddr....
i was using the follow approch.
Java
try
{
System.Diagnostics.Process[] HandleP= System.Diagnostics.Process.GetProcessesByName("ProcessByName.exe");
System.Diagnostics.ProcessModuleCollectionmodules= HandleP[0].Modules;
foreach (System.Diagnostics.ProcessModule i in modules)
{
if (i.ModuleName == "ModuleNeeded") { ThisModule = i.BaseAddress.ToInt32(); }
}
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.ToString());
}
But it always gives me the follow error:
Code
A first chance exception of type 'System.IndexOutOfRangeException' occurred in MyApp.exe
An unhandled exception of type 'System.IndexOutOfRangeException' occurred in MyApp.exe
Additional information: Index was outside the bounds of the array.
So i am assuming it is not finding any module ? is that right ?
SOLVED
Code
if (HandleP.Length == 1) {
foreach (System.Diagnostics.ProcessModule i in modules) {
....
I use this same code for other stuff and it worked just fine...
Well appreciate any help thx.
Answers
Know the answer? Post it. Somebody with the same question will find it here.
Answers
Know the answer? Post it. Somebody with the same question will find it here.