Example #1
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.sc = new ServiceContainer();
     loader = mr.Stub<ILoader>();
     arch = mr.StrictMock<IProcessorArchitecture>();
     this.listener = mr.Stub<DecompilerEventListener>();
     Address dummy;
     arch.Stub(a => a.TryParseAddress(null, out dummy)).IgnoreArguments().WhenCalled(m =>
     {
         Address addr;
         var sAddr = (string)m.Arguments[0];
         var iColon = sAddr.IndexOf(':');
         if (iColon > 0)
         {
             addr = Address.SegPtr(
                 Convert.ToUInt16(sAddr.Remove(iColon)),
                 Convert.ToUInt16(sAddr.Substring(iColon+1)));
             m.ReturnValue = true;
         }
         else
         {
             m.ReturnValue = Address32.TryParse32((string)m.Arguments[0], out addr);
         }
         m.Arguments[1] = addr;
     }).Return(false);
     this.cfgSvc = mr.Stub<IConfigurationService>();
     this.sc.AddService<IConfigurationService>(cfgSvc);
 }
Example #2
0
        public DataFlowAnalysis(Program program, IImportResolver importResolver, DecompilerEventListener eventListener)
		{
			this.program = program;
            this.importResolver = importResolver;
            this.eventListener = eventListener;
			this.flow = new ProgramDataFlow(program);
		}
Example #3
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.sc = new ServiceContainer();
     this.listener = mr.Stub<DecompilerEventListener>();
     this.sc.AddService<DecompilerEventListener>(listener);
 }
Example #4
0
 public void Setup()
 {
     mr = new MockRepository();
     sc = new ServiceContainer();
     listener = mr.Stub<DecompilerEventListener>();
     sc.AddService<DecompilerEventListener>(listener);
     sc.AddService<DecompilerHost>(new FakeDecompilerHost());
 }
Example #5
0
 public ImportResolver(Project project, Program program, DecompilerEventListener eventListener)
 {
     if (project == null)
         throw new ArgumentNullException("project");
     this.project = project;
     this.program = program;
     this.eventListener = eventListener;
 }
Example #6
0
 /// <summary>
 /// For each procedure, either use a user-supplied signature, 
 /// or the predefined one.
 /// </summary>
 public void BuildSignatures(DecompilerEventListener listener)
 {
     foreach (var de in program.Procedures)
     {
         if (listener.IsCanceled())
             break;
         BuildSignature(de.Key, de.Value);
     }
 }
Example #7
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.mockFactory = new MockFactory(mr);
     this.sc = new ServiceContainer();
     this.cfgSvc = mr.Stub<IConfigurationService>();
     this.listener = mr.Stub<DecompilerEventListener>();
     this.sc.AddService<IConfigurationService>(cfgSvc);
 }
Example #8
0
 public ShingledScanner(Program program, IRewriterHost host, DecompilerEventListener eventListener)
 {
     this.program = program;
     this.host = host;
     this.eventListener = eventListener;
     this.bad = program.Platform.MakeAddressFromLinear(~0ul);
     this.possibleCallDestinationTallies = new Dictionary<Address,int>();
     this.possiblePointerTargetTallies = new Dictionary<Address, int>();
     this.instructions = new SortedList<Address, MachineInstruction>();
 }
Example #9
0
 public TypedExpressionRewriter(Program program, DecompilerEventListener eventListener)
 {
     this.program = program;
     this.globals = program.Globals;
     this.eventListener = eventListener;
     this.compTypes = new DataTypeComparer();
     this.tcr = new TypedConstantRewriter(program, eventListener);
     this.m = new ExpressionEmitter();
     this.unifier = new Unifier();
 }
Example #10
0
 public DecompilerDriver(ILoader ldr, IServiceProvider services)
 {
     if (ldr == null)
         throw new ArgumentNullException("ldr");
     if (services == null)
         throw new ArgumentNullException("services");
     this.loader = ldr;
     this.host = services.RequireService<DecompilerHost>();
     this.services = services;
     this.eventListener = services.GetService<DecompilerEventListener>();
 }
Example #11
0
 public static void Rewrite(Program program, DecompilerEventListener listener)
 {
     var crw = new CallRewriter(program);
     foreach (Procedure proc in program.Procedures.Values)
     {
         if (listener.IsCanceled())
             break;
         crw.RewriteCalls(proc);
         crw.RewriteReturns(proc);
     }
 }
Example #12
0
 public IndirectCallRewriter(
     Program program,
     SsaState ssa,
     DecompilerEventListener eventListener)
 {
     this.program = program;
     this.proc = ssa.Procedure;
     this.ssa = ssa;
     this.asc = new IndirectCallTypeAscender(program);
     this.expander = new IndirectCallExpander(ssa);
     this.ssaIdTransformer = new SsaIdentifierTransformer(ssa);
     this.eventListener = eventListener;
 }
Example #13
0
        public void Setup()
        {
            exit = new ExternalProcedure("exit", 
                new FunctionType(
                    null, 
                    null, 
                    new Identifier("retCode", PrimitiveType.Int32, new StackArgumentStorage(0, PrimitiveType.Int32))));
            exit.Characteristics = new ProcedureCharacteristics();
            exit.Characteristics.Terminates = true;

            progMock = new ProgramBuilder();
            flow = new ProgramDataFlow();
            eventListener = new FakeDecompilerEventListener();
        }
 public TrashedRegisterFinder2(
     IProcessorArchitecture arch,
     ProgramDataFlow flow,
     Procedure proc,
     SsaIdentifierCollection ssa,
     DecompilerEventListener listener)
 {
     this.arch = arch;
     this.progFlow = flow;
     this.proc = proc;
     this.ssa = ssa;
     this.decompilerEventListener = listener;
     this.flow = new ProcedureFlow2();
 }
Example #15
0
 public void Setup()
 {
     this.mr = new MockRepository();
     this.sc = new ServiceContainer();
     this.eventListener = mr.Stub<DecompilerEventListener>();
     this.sc.AddService(typeof(DecompilerEventListener), this.eventListener);
     var arch = mr.Stub<IProcessorArchitecture>();
     var platform = mr.Stub<IPlatform>();
     arch.Stub(a => a.WordWidth).Return(PrimitiveType.Word32);
     platform.Stub(p => p.Architecture).Return(arch);
     platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Long)).Return(4);
     platform.Stub(p => p.GetByteSizeFromCBasicType(CBasicType.Double)).Return(8);
     platform.Stub(p => p.PointerType).Return(PrimitiveType.Pointer32);
     this.program = new Program { Platform = platform };
 }
Example #16
0
 public TypeCollector(
     TypeFactory factory, 
     TypeStore store,
     Program program,
     DecompilerEventListener eventListener)
 {
     this.factory = factory;
     this.store = store;
     this.program = program;
     if (eventListener == null)
         throw new ArgumentNullException("eventListener");
     this.eventListener = eventListener;
     this.asc = new ExpressionTypeAscender(program, store, factory);
     this.desc = new ExpressionTypeDescender(program, store, factory);
 }
Example #17
0
 public void Setup()
 {
     mr = new MockRepository();
     fakeArch = new FakeArchitecture();
     importResolver = mr.StrictMock<IImportResolver>();
     callSigs = new Dictionary<Address, FunctionType>();
     this.eventListener = new FakeDecompilerEventListener();
     arch = fakeArch;
     var r1 = arch.GetRegister(1);
     reg1 = new Identifier(r1.Name, PrimitiveType.Word32, r1);
     this.sc = new ServiceContainer();
     sc.AddService<DecompilerHost>(new FakeDecompilerHost());
     sc.AddService<DecompilerEventListener>(eventListener);
     sc.AddService<IFileSystemService>(new FileSystemServiceImpl());
 }
Example #18
0
 public virtual void Setup()
 {
     mr            = new MockRepository();
     eventListener = mr.Stub <DecompilerEventListener>();
 }
Example #19
0
 public CallRewriter(IPlatform platform, ProgramDataFlow mpprocflow, DecompilerEventListener listener)
 {
     this.platform   = platform;
     this.mpprocflow = mpprocflow;
     this.listener   = listener;
 }
Example #20
0
 public TypeTransformer(TypeFactory factory, TypeStore store, Program program, DecompilerEventListener eventListener)
 {
     this.factory       = factory;
     this.store         = store;
     this.program       = program;
     this.eventListener = eventListener;
     this.unifier       = new Unifier(factory, trace);
     this.visitedTypes  = new Dictionary <DataType, DataType>();
 }
Example #21
0
 public AddressContext(Program program, Address addr, DecompilerEventListener decompilerEventListener)
 {
     this.program = program;
     this.addr    = addr;
     this.decompilerEventListener = decompilerEventListener;
 }
Example #22
0
 public ImportResolver(Project project, Program program, DecompilerEventListener eventListener)
 {
     this.project       = project ?? throw new ArgumentNullException("project");
     this.program       = program;
     this.eventListener = eventListener;
 }
Example #23
0
        public bool ReplaceAll(DecompilerEventListener eventListener)
        {
            changed            = false;
            classesVisited     = new HashSet <EquivalenceClass>();
            this.eventListener = eventListener;

            // Replace the DataType of all the equivalence classes
            foreach (TypeVariable tv in store.TypeVariables)
            {
                if (eventListener.IsCanceled())
                {
                    return(false);
                }
                EquivalenceClass eq = tv.Class;
                if (!classesVisited.Contains(eq))
                {
                    classesVisited.Add(eq);
                    var dt = Replace(eq.DataType);
                    eq.DataType = dt;
                }
            }

            // Replace the DataType of all the TypeVariables
            foreach (TypeVariable tv in store.TypeVariables)
            {
                if (eventListener.IsCanceled())
                {
                    return(false);
                }
                tv.DataType = Replace(tv.DataType);
            }

            foreach (EquivalenceClass eq in classesVisited)
            {
                if (eventListener.IsCanceled())
                {
                    return(false);
                }
                if (eq != program.Globals.TypeVariable.Class &&
                    (eq.DataType is PrimitiveType ||
                     eq.DataType is VoidType ||
                     eq.DataType is EquivalenceClass ||
                     eq.DataType is CodeType))
                {
                    eq.DataType = null;
                    changed     = true;
                    continue;
                }

                Pointer ptr = eq.DataType as Pointer;
                if (ptr != null)
                {
                    eq.DataType = ptr.Pointee;
                    changed     = true;
                    continue;
                }

                MemberPointer mp = eq.DataType as MemberPointer;
                if (mp != null)
                {
                    eq.DataType = mp.Pointee;
                    changed     = true;
                }

                ArrayType array = eq.DataType as ArrayType;
                if (array != null)
                {
                    eq.DataType = array.ElementType;
                    changed     = true;
                }
            }
            return(changed);
        }
Example #24
0
 public Arm64Relocator(IServiceProvider services, Program program) : base(program)
 {
     this.eventListener = services.RequireService <DecompilerEventListener>();
 }
Example #25
0
 public HeuristicScanner(Program program, IRewriterHost host, DecompilerEventListener eventListener)
 {
     this.program = program;
     this.host = host;
     this.eventListener = eventListener;
 }
Example #26
0
 public DataFlowAnalysis(Program prog, DecompilerEventListener eventListener)
 {
     this.program       = prog;
     this.eventListener = eventListener;
     this.flow          = new ProgramDataFlow(prog);
 }
Example #27
0
        public override Dictionary <string, IDictionary <Address, IAddressable> > GetObjectPlacements(string fileExtension, DecompilerEventListener listener)
        {
            this.defaultFile     = Path.ChangeExtension(program.Name, fileExtension);
            this.defaultDataFile = Path.ChangeExtension(program.Name, "globals" + fileExtension);

            // Find the segment for each procedure
            var result = new Dictionary <string, IDictionary <Address, IAddressable> >();

            foreach (var proc in program.Procedures.Values)
            {
                PlaceObject(proc, defaultFile, result);
            }

            // Place all global objects.
            var wl = new WorkList <(StructureField, Address)>(
                MakeGlobalWorkItems()
                .Concat(MakeSegmentWorkitems()));
            var objectTracer = new GlobalObjectTracer(program, wl, listener);

            while (wl.GetWorkItem(out var item))
            {
                var(field, addr) = item;
                var globalVar = new GlobalVariable(addr, field.DataType, program.NamingPolicy.GlobalName(field));
                PlaceObject(globalVar, defaultDataFile, result);
                objectTracer.TraceObject(field.DataType, addr);
            }
            return(result);
        }
Example #28
0
 public DecompiledFileService(IFileSystemService fsSvc, DecompilerEventListener listener)
 {
     this.fsSvc    = fsSvc;
     this.listener = listener;
 }
Example #29
0
 /// <summary>
 /// Returns a placement mapping for rendering high-level items.
 /// </summary>
 /// <param name="fileExtension"></param>
 /// <returns></returns>
 public abstract Dictionary <string, IDictionary <Address, IAddressable> > GetObjectPlacements(
     string fileExtension,
     DecompilerEventListener listener);
Example #30
0
 public ScannerBase(Program program, DecompilerEventListener eventListener)
 {
     this.Program           = program;
     this.eventListener     = eventListener;
     this.noDecompiledProcs = new Dictionary <Address, Procedure_v1>();
 }
Example #31
0
 public WebBuilder(Program program, SsaState ssa, Dictionary <Identifier, LinearInductionVariable> ivs, DecompilerEventListener listener)
 {
     this.program  = program;
     this.ssa      = ssa;
     this.ssaIds   = ssa.Identifiers;
     this.ivs      = ivs;
     this.listener = listener;
     this.doms     = ssa.Procedure.CreateBlockDominatorGraph();
     this.webs     = new List <Web>();
     this.webOf    = new Dictionary <Identifier, Web>();
 }
Example #32
0
 private IScanner CreateScanner(Program program, DecompilerEventListener eventListener)
 {
     return new Scanner(
         program,
         LoadCallSignatures(program, program.UserCalls.Values),
         new ImportResolver(project),
         eventListener);
 }
Example #33
0
 public DataFlowAnalysis(Program prog, DecompilerEventListener eventListener)
 {
     this.program = prog;
     this.eventListener = eventListener;
     this.flow = new ProgramDataFlow(prog);
 }
Example #34
0
 public SparseValuePropagation(SsaState ssa, Program program, IDynamicLinker resolver, DecompilerEventListener listener)
 {
     this.ssa      = ssa;
     this.listener = listener;
     this.cmp      = new ExpressionValueComparer();
     this.ctx      = new SparseEvaluationContext(ssa.Procedure.Architecture);
     this.eval     = new Evaluation.ExpressionSimplifier(program.SegmentMap, ctx, listener);
 }
Example #35
0
 public GlobalCallRewriter(Program program, ProgramDataFlow mpprocflow, DecompilerEventListener eventListener) : base(program)
 {
     this.mpprocflow = mpprocflow;
 }
Example #36
0
 public TerminationAnalysis(ProgramDataFlow flow, DecompilerEventListener eventListener)
 {
     this.flow = flow;
     this.eventListener = eventListener;
 }
Example #37
0
 public ProjectLoader(IServiceProvider services, ILoader loader, DecompilerEventListener listener)
     : this(services, loader, new Project(), listener)
 {
 }
Example #38
0
 public virtual void Setup()
 {
     mr = new MockRepository();
     eventListener = mr.Stub<DecompilerEventListener>();
 }
Example #39
0
 public TerminationAnalysis(ProgramDataFlow flow, DecompilerEventListener eventListener)
 {
     this.flow          = flow;
     this.eventListener = eventListener;
 }
Example #40
0
		public GlobalCallRewriter(Program program, ProgramDataFlow mpprocflow, DecompilerEventListener eventListener) : base(program)
		{
			this.mpprocflow = mpprocflow;
		}
Example #41
0
        public static ImageSegment?LoadSegment(MemorySegment_v1 segment, IPlatform platform, DecompilerEventListener listener)
        {
            if (segment.Name is null)
            {
                listener.Warn("Memory map segments must have names.");
                return(null);
            }

            if (!platform.TryParseAddress(segment.Address, out var addr))
            {
                listener.Warn(
                    "Unable to parse address '{0}' in memory map segment {1}.",
                    segment.Address !,
                    segment.Name !);
                return(null);
            }
            if (!uint.TryParse(segment.Size, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var size))
            {
                listener.Warn(
                    "Unable to parse hexadecimal size '{0}' in memory map segment {1}.",
                    segment.Size !,
                    segment.Name !);
                return(null);
            }

            var mem = new ByteMemoryArea(addr, new byte[size]);

            return(new ImageSegment(segment.Name, mem, ConvertAccess(segment.Attributes)));
        }
Example #42
0
        public TableExtent?DiscoverTableExtent(Address addrSwitch, RtlTransfer xfer, DecompilerEventListener listener)
        {
            if (!Start(rtlBlock, host.BlockInstructionCount(rtlBlock) - 1, xfer.Target))
            {
                // No registers were found, so we can't trace back.
                return(null);
            }
            while (Step())
            {
                ;
            }

            var jumpExpr = this.JumpTableFormat;
            var interval = this.JumpTableIndexInterval;
            var index    = this.JumpTableIndexToUse;
            var ctx      = new Dictionary <Expression, ValueSet>(new ExpressionValueComparer());

            if (index == null)
            {
                // Weren't able to find the index register,
                // try finding it by blind pattern matching.
                index = this.FindIndexWithPatternMatch(this.JumpTableFormat);
                if (index == null)
                {
                    // This is likely an indirect call like a C++
                    // vtable dispatch. Since these are common, we don't
                    // spam the user with warnings.
                    return(null);
                }

                // We have a jump table, and we've guessed the index expression.
                // At this point we've given up on knowing the exact size
                // of the table, but we do know that it must be at least
                // more than one entry. The safest assumption is that it
                // has two entries.
                listener.Warn(
                    listener.CreateAddressNavigator(host.Program, addrSwitch),
                    "Unable to determine size of call or jump table; there may be more than 2 entries.");
                ctx.Add(index, new IntervalValueSet(index.DataType, StridedInterval.Create(1, 0, 1)));
            }
            else if (interval.IsEmpty)
            {
                return(null);
            }
            else if (interval.High == Int64.MaxValue)
            {
                // We have no reasonable upper bound. We make the arbitrary
                // assumption that the jump table has 2 items; it wouldn't
                // make sense to be indexing otherwise.
                listener.Warn(
                    listener.CreateAddressNavigator(host.Program, addrSwitch),
                    "Unable to determine the upper bound of an indirect call or jump; there may be more than 2 entries.");
                var vs = new IntervalValueSet(
                    this.JumpTableIndex !.DataType,
                    StridedInterval.Create(1, interval.Low, interval.Low + 1));
                ctx.Add(this.JumpTableIndexToUse !, vs);
            }
            else
            {
                ctx.Add(this.JumpTableIndex !, new IntervalValueSet(this.JumpTableIndex !.DataType, interval));
            }
            var vse = new ValueSetEvaluator(host.Architecture, host.SegmentMap, ctx, this.processorState);

            var(values, accesses) = vse.Evaluate(jumpExpr !);
            var vector = values.Values
                         .TakeWhile(c => !(c is InvalidConstant))
                         .Take(2000)    // Arbitrary limit
                         .Select(ForceToAddress)
                         .TakeWhile(a => !(a is null))
                         .ToList() !;

            if (vector.Count == 0)
            {
                return(null);
            }
            return(new TableExtent
            {
                Targets = vector !,
                Accesses = accesses,
                Index = index,
            });
Example #43
0
 public MipsRelocator(IServiceProvider services, Program program) : base(program)
 {
     dcSvc = services.RequireService <DecompilerEventListener>();
 }
Example #44
0
		public bool ReplaceAll(DecompilerEventListener eventListener)
		{
			changed = false;
			classesVisited  = new HashSet<EquivalenceClass>();

            // Replace the DataType of all the equivalence classes
			foreach (TypeVariable tv in store.TypeVariables)
			{
                if (eventListener.IsCanceled())
                    return false;
				EquivalenceClass eq = tv.Class;
				if (!classesVisited.Contains(eq))
				{
					classesVisited.Add(eq);
                    var dt = Replace(eq.DataType);
                    eq.DataType = dt;
				}
			}

            // Replace the DataType of all the TypeVariables
			foreach (TypeVariable tv in store.TypeVariables)
			{
                if (eventListener.IsCanceled())
                    return false;
                tv.DataType = Replace(tv.DataType);
			}

			foreach (EquivalenceClass eq in classesVisited)
			{
                if (eventListener.IsCanceled())
                    return false;
                if (eq != program.Globals.TypeVariable.Class &&
                    (eq.DataType is PrimitiveType ||
                    eq.DataType is VoidType ||
					eq.DataType is EquivalenceClass ||
                    eq.DataType is CodeType))
				{
					eq.DataType = null;
					changed = true;
					continue;
				}
				
				Pointer ptr = eq.DataType as Pointer;
				if (ptr != null)
				{
					eq.DataType = ptr.Pointee;
					changed = true;
					continue;
				}

				MemberPointer mp = eq.DataType as MemberPointer;
				if (mp != null)
				{
					eq.DataType = mp.Pointee;
					changed = true;
				}

                ArrayType array = eq.DataType as ArrayType;
                if (array != null)
                {
                    eq.DataType = array.ElementType;
                    changed = true;
                }
			}
			return changed;
		}
Example #45
0
 public TypeAnalyzer(DecompilerEventListener eventListener)
 {
     this.eventListener = eventListener;
 }
Example #46
0
 public Scanner(
     Program program, 
     IImportResolver importResolver,
     IServiceProvider services)
 {
     this.program = program;
     this.segmentMap = program.SegmentMap;
     this.importResolver = importResolver;
     this.Services = services;
     this.eventListener = services.RequireService<DecompilerEventListener>();
     this.cancelSvc = services.GetService<CancellationTokenSource>();
     if (segmentMap == null)
         throw new InvalidOperationException("Program must have an segment map.");
     if (program.ImageMap == null)
     {
         program.ImageMap = segmentMap.CreateImageMap();
     }
     this.imageMap = program.ImageMap;
     this.queue = new PriorityQueue<WorkItem>();
     this.blocks = new SortedList<Address, BlockRange>();
     this.blockStarts = new Dictionary<Block, Address>();
     this.pseudoProcs = program.PseudoProcedures;
     this.importReferences = program.ImportReferences;
     this.visitedProcs = new HashSet<Procedure>();
     this.noDecompiledProcs = new Dictionary<Address, Procedure_v1>();
 }
Example #47
0
 public TypeTransformer(TypeFactory factory, TypeStore store, Program program, DecompilerEventListener eventListener)
 {
     this.factory       = factory;
     this.store         = store;
     this.program       = program;
     this.eventListener = eventListener;
     this.unifier       = new Unifier(factory);
     this.comparer      = new DataTypeComparer();
     this.visitedTypes  = new HashSet <DataType>();
 }
Example #48
0
 public MipsRelocator(IServiceProvider services, Program program) : base(program)
 {
     dcSvc = services.RequireService<DecompilerEventListener>();
 }
Example #49
0
 public ScannerInLinq(IServiceProvider services, Program program, IRewriterHost host, DecompilerEventListener eventListener)
 {
     this.services      = services;
     this.program       = program;
     this.host          = host;
     this.eventListener = eventListener;
 }
Example #50
0
 public NroLoader(IServiceProvider services, ImageLocation imageLocation, byte[] imgRaw)
     : base(services, imageLocation, imgRaw)
 {
     decompilerEventListener = services.RequireService <DecompilerEventListener>();
     rdr = new LeImageReader(RawImage, 0);
 }
Example #51
0
 public AddressContext(Program prog, Address addr, DecompilerEventListener decompilerEventListener)
 {
     this.program = prog;
     this.addr = addr;
     this.decompilerEventListener = decompilerEventListener;
 }
Example #52
0
 public PtrPrimitiveReplacer(TypeFactory factory, TypeStore store, Program program, DecompilerEventListener eventListener)
 {
     this.factory        = factory;
     this.store          = store;
     this.program        = program;
     this.eventListener  = eventListener;
     this.visitedTypes   = new HashSet <DataType>();
     this.classesVisited = new HashSet <EquivalenceClass>();
 }
Example #53
0
 public Scanner(
     Program program, 
     IDictionary<Address, ProcedureSignature> callSigs,
     IImportResolver importResolver,
     DecompilerEventListener eventListener)
 {
     this.program = program;
     this.image = program.Image;
     this.imageMap = program.ImageMap;
     this.importResolver = importResolver;
     this.callSigs = callSigs;
     this.eventListener = eventListener;
     if (imageMap == null)
         throw new InvalidOperationException("Program must have an image map.");
     this.queue = new PriorityQueue<WorkItem>();
     this.blocks = new Map<Address, BlockRange>();
     this.blockStarts = new Dictionary<Block, Address>();
     this.pseudoProcs = program.PseudoProcedures;
     this.vectors = program.Vectors;
     this.importReferences = program.ImportReferences;
     this.visitedProcs = new HashSet<Procedure>();
 }
Example #54
0
 public AdjacentBranchCollector(Procedure proc, DecompilerEventListener listener)
 {
     this.proc     = proc;
     this.listener = listener;
     this.cmp      = new ExpressionValueComparer();
 }
Example #55
0
 public NroLoader(IServiceProvider services, string filename, byte[] imgRaw) : base(services, filename, imgRaw)
 {
     decompilerEventListener = services.RequireService <DecompilerEventListener>();
     rdr = new LeImageReader(RawImage, 0);
 }
Example #56
0
 public ShingledScanner(Program program, IRewriterHost host, IStorageBinder storageBinder, ScanResults sr, DecompilerEventListener eventListener)
 {
     this.program                    = program;
     this.host                       = host;
     this.storageBinder              = storageBinder;
     this.sr                         = sr;
     this.eventListener              = eventListener;
     this.sr.TransferTargets         = new HashSet <Address>();
     this.sr.DirectlyCalledAddresses = new Dictionary <Address, int>();
     this.sr.Instructions            = new SortedList <Address, RtlInstructionCluster>();
     this.sr.FlatInstructions        = new SortedList <Address, ScanResults.instr>();
     this.sr.FlatEdges               = new List <ScanResults.link>();
     this.G   = new DiGraph <Address>();
     this.Bad = program.Platform.MakeAddressFromLinear(~0ul);
     G.AddNode(Bad);
 }
Example #57
0
		public static void Rewrite(
            Program program, 
            ProgramDataFlow summaries,
            DecompilerEventListener eventListener)
		{
			GlobalCallRewriter crw = new GlobalCallRewriter(program, summaries, eventListener);
			foreach (Procedure proc in program.Procedures.Values)
			{
                if (eventListener.IsCanceled())
                    return;
				ProcedureFlow flow = crw.mpprocflow[proc];
                flow.Dump(program.Architecture);
				crw.AdjustLiveOut(flow);
				crw.EnsureSignature(proc, flow);
				crw.AddUseInstructionsForOutArguments(proc);
			}

			foreach (Procedure proc in program.Procedures.Values)
			{
                if (eventListener.IsCanceled())
                    return;
                crw.RewriteCalls(proc);
				crw.RewriteReturns(proc);
			}
		}
Example #58
0
 public ShingledScanner(Program program, IRewriterHost host, IStorageBinder storageBinder, ScanResults sr, DecompilerEventListener eventListener)
 {
     this.program       = program;
     this.host          = host;
     this.storageBinder = storageBinder;
     this.sr            = sr;
     this.eventListener = eventListener;
     this.Bad           = program.Platform.MakeAddressFromLinear(~0ul, false);
 }
Example #59
0
 public TypeAnalyzer(DecompilerEventListener eventListener)
 {
     this.eventListener = eventListener;
 }
Example #60
0
 public StructureAnalysis(DecompilerEventListener listener, Program program, Procedure proc)
 {
     this.eventListener = listener;
     this.program = program;
     this.proc = proc;
 }