private void addBreakpointsToAllMethodsInModule(string moduleToProcess, bool verbose)
 {
     DI.log.debug("Adding {0} breakpoints", methodsInModule.Count);
     O2Thread.mtaThread(() =>
     {
         var numberOfBreakpointsAdded = 0;
         var breakpointOffset         = 0;
         var timer         = new O2Timer("Breakpoint added in").start();
         MDbgModule module = DI.o2MDbg.sessionData.getModule(moduleToProcess);
         if (module != null)
         {
             foreach (Type typeInModule in module.Importer.DefinedTypes)
             {
                 // no point in adding interfaces or abstract types since they will not be bound (double check on abstract!!)
                 //if (false == typeInModule.IsInterface && false == typeInModule.IsAbstract)   // these are not implemented in the original MDbg :(
                 foreach (MethodInfo methodInType in typeInModule.GetMethods())
                 {
                     DI.o2MDbg.BreakPoints.add(moduleToProcess, typeInModule.FullName,
                                               methodInType.Name, breakpointOffset,
                                               verbose);
                     if (numberOfBreakpointsAdded++ % 500 == 0)
                     {
                         DI.log.info(
                             "  update: {0} breakpoints added so far of a max of {1}",
                             numberOfBreakpointsAdded, methodsInModule.Count);
                     }
                 }
             }
         }
         timer.stop();
         DI.log.info("There where {0} breakpoints added of a max of {1}", numberOfBreakpointsAdded, methodsInModule.Count);
     });
 }
Exemple #2
0
        public static List <MetadataType> types(this MDbgModule module)
        {
            var types = new List <MetadataType>();

            foreach (MetadataType type in module.Importer.DefinedTypes)
            {
                types.add(type);
            }
            return(types);
        }
Exemple #3
0
 public static CorFunction corFunction(this MethodInfo type, MDbgModule module)
 {
     return(module.CorModule.GetFunctionFromToken(type.MetadataToken));
 }
Exemple #4
0
 public static MetadataType type(this MDbgModule module, string typeName)
 {
     return((from type in module.types()
             where type.Name == typeName
             select type).first());
 }
        public static void EncCmd(string args)
        {
            var ap = new ArgParser(args);

            if (ap.Count == 0)
            {
                WriteOutput("Performed edits:");
                foreach (MDbgModule module in Debugger.Processes.Active.Modules)
                {
                    if (module.EditsCounter > 0)
                    {
                        WriteOutput(module.CorModule.Name);
                        int edits = module.EditsCounter;
                        for (int j = 1; j <= edits; j++)
                        {
                            string editFile = module.GetEditsSourceFile(j);
                            WriteOutput(String.Format(CultureInfo.InvariantCulture, "   {0}. - {1}",
                                                      new Object[] { j, editFile == null ? "N/A" : editFile }));
                        }
                    }
                }
                return;
            }
            if (ap.Count < 1 && ap.Count > 3)
            {
                WriteError("Wrong amount of arguments!");
                return;
            }
            string encModule = ap.AsString(0);

            MDbgModule m       = Debugger.Processes.Active.Modules.Lookup(encModule);
            string     modName = Path.DirectorySeparatorChar +
                                 Path.GetFileName(m.CorModule.Name);

            string pathToEncFiles = Path.GetDirectoryName(m.CorModule.Name); // defaults to location of the module

            string editSourceFile;

            if (ap.Exists(1))
            {
                editSourceFile = ap.AsString(1);
            }
            else
            {
                editSourceFile = null;
            }

            string deltasBaseName;

            if (ap.Exists(2))
            {
                deltasBaseName = ap.AsString(2);
            }
            else
            {
                deltasBaseName = pathToEncFiles + modName + ".1";
            }

            string deltaPdbFile = deltasBaseName + ".pdb";

            if (!File.Exists(deltaPdbFile))
            {
                WriteOutput("Delta PDB file not found; debug symbols won't be updated.");
                deltaPdbFile = null;
            }

            m.ApplyEdit(deltasBaseName + ".dmeta",
                        deltasBaseName + ".dil",
                        deltaPdbFile,
                        editSourceFile);

            WriteOutput("ENC successfully applied.");
        }