예제 #1
0
        public override void Invoke()
        {
            if (Runtime == null)
            {
                throw new DiagnosticsException("No CLR runtime set");
            }
            Regex regex = ModuleName is not null ? new Regex(ModuleName, RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant) : null;

            foreach (ClrModule module in Runtime.EnumerateModules())
            {
                if (regex is null || !string.IsNullOrEmpty(module.Name) && regex.IsMatch(Path.GetFileName(module.Name)))
                {
                    if (Verbose)
                    {
                        WriteLine("{0}{1}", module.Name, module.IsDynamic ? "(Dynamic)" : "");
                        WriteLine("    AssemblyName:    {0}", module.AssemblyName);
                        WriteLine("    ImageBase:       {0:X16}", module.ImageBase);
                        WriteLine("    Size:            {0:X8}", module.Size);
                        WriteLine("    Address:         {0:X16}", module.Address);
                        WriteLine("    IsPEFile:        {0}", module.IsPEFile);
                        WriteLine("    Layout:          {0}", module.Layout);
                        WriteLine("    IsDynamic:       {0}", module.IsDynamic);
                        WriteLine("    MetadataAddress: {0:X16}", module.MetadataAddress);
                        WriteLine("    MetadataSize:    {0:X16}", module.MetadataLength);
                        WriteLine("    PdbInfo:         {0}", module.Pdb?.ToString() ?? "<none>");
                        VersionData version = null;
                        try
                        {
                            version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).VersionData;
                        }
                        catch (DiagnosticsException)
                        {
                        }
                        WriteLine("    Version:         {0}", version?.ToString() ?? "<none>");
                    }
                    else
                    {
                        WriteLine("{0:X16} {1:X8} {2}{3}", module.ImageBase, module.Size, module.Name, module.IsDynamic ? "(Dynamic)" : "");
                    }
                }
            }
        }
예제 #2
0
 public override void Invoke()
 {
     if (Runtime == null)
     {
         throw new DiagnosticsException("No CLR runtime set");
     }
     foreach (ClrModule module in Runtime.EnumerateModules())
     {
         if (Verbose)
         {
             WriteLine("{0}{1}", module.Name, module.IsDynamic ? "(Dynamic)" : "");
             WriteLine("    AssemblyName:    {0}", module.AssemblyName);
             WriteLine("    ImageBase:       {0:X16}", module.ImageBase);
             WriteLine("    Size:            {0:X8}", module.Size);
             WriteLine("    Address:         {0:X16}", module.Address);
             WriteLine("    IsPEFile:        {0}", module.IsPEFile);
             WriteLine("    Layout:          {0}", module.Layout);
             WriteLine("    IsDynamic:       {0}", module.IsDynamic);
             WriteLine("    MetadataAddress: {0:X16}", module.MetadataAddress);
             WriteLine("    MetadataSize:    {0:X16}", module.MetadataLength);
             WriteLine("    PdbInfo:         {0}", module.Pdb?.ToString() ?? "<none>");
             VersionInfo?version = null;
             try
             {
                 version = ModuleService.GetModuleFromBaseAddress(module.ImageBase).Version;
             }
             catch (DiagnosticsException)
             {
             }
             WriteLine("    Version:         {0}", version?.ToString() ?? "<none>");
         }
         else
         {
             WriteLine("{0:X16} {1:X8} {2}{3}", module.ImageBase, module.Size, module.Name, module.IsDynamic ? "(Dynamic)" : "");
         }
     }
 }