Enumerate over mods in a given PID : Process : Development C# Examples


C# Examples » Development » Process »

 

Enumerate over mods in a given PID









    
using  System;
using  System.Diagnostics;

class  MainClass
{
    public  static  void  EnumModsForPid(int  pID)
    {
        Process  theProc;

        try  {
                theProc  =  Process.GetProcessById(pID);
            }  catch  {
            Console.WriteLine("->  Sorry...bad  PID!");
            return;
        }
        
        Console.WriteLine("Here  are  the  loaded  modules  for:  {0}",  theProc.ProcessName);
        try
        {
            ProcessModuleCollection  theMods  =  theProc.Modules;
            foreach(ProcessModule  pm  in  theMods)
            {
                string  info  =  string.Format("->  Mod  Name:  {0}",  pm.ModuleName);
                Console.WriteLine(info);
            }
        }
        catch{Console.WriteLine("No  mods!");}
    }

    static  void  Main(string[]  args)
    {
        int  theProcID  =  10001;
        EnumModsForPid(theProcID);
    }
}
    
   
  
   



Output

-> Sorry...bad PID!


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Development
» Process