0
Answer

Read Executable Module

Ask a question
Prix One

Prix One

14y
2k
1
Hi,

I am not well knowledge with memory stuff etc...

I need to get the modules from a process so i can get it is baseAddr....

i was using the follow approch.

                 try
                {
                    System.Diagnostics.Process[] HandleP = System.Diagnostics.Process.GetProcessesByName("ProcessByName.exe");
                    System.Diagnostics.ProcessModuleCollection modules = 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:

 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
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.