/// Plan of attack: /// In each unscanned "hole", look for signatures of procedure entries. /// These are procedure entry candidates. /// Scan each of the procedure entry candidates heuristically. /// /// Next scan all executable code segments for: /// - calls that reach those candidates /// - jmps to those candidates /// - pointers to those candidates. /// Each time we find a call, we increase the score of the candidate. /// At the end we have a list of scored candidates. public void ScanImageHeuristically() { var sw = new Stopwatch(); sw.Start(); var list = new List <HeuristicBlock>(); var ranges = FindUnscannedRanges(); var fnRanges = FindPossibleFunctions(ranges).ToList(); int n = 0; foreach (var range in fnRanges) { var hproc = DisassembleProcedure(range.Item1, range.Item2); var hps = new HeuristicProcedureScanner(program, hproc, host); hps.BlockConflictResolution(); DumpBlocks(hproc.Cfg.Nodes); hps.GapResolution(); // TODO: add all guessed code to image map -- clearly labelled. AddBlocks(hproc); list.AddRange(hproc.Cfg.Nodes); eventListener.ShowProgress("Estimating procedures", n, fnRanges.Count); ++n; } eventListener.Warn( new Reko.Core.Services.NullCodeLocation("Heuristics"), string.Format("Scanned image in {0} seconds, finding {1} blocks.", sw.Elapsed.TotalSeconds, list.Count)); list.ToString(); }
/// Plan of attack: /// In each unscanned "hole", look for signatures of procedure entries. /// These are procedure entry candidates. /// Scan each of the procedure entry candidates heuristically. /// /// Next scan all executable code segments for: /// - calls that reach those candidates /// - jmps to those candidates /// - pointers to those candidates. /// Each time we find a call, we increase the score of the candidate. /// At the end we have a list of scored candidates. public void ScanImageHeuristically() { var ranges = FindUnscannedRanges(); foreach (var range in FindPossibleFunctions(ranges)) { var hproc = DisassembleProcedure(range.Item1, range.Item2); var hps = new HeuristicProcedureScanner(program, hproc, host); hps.BlockConflictResolution(); DumpBlocks(hproc.Cfg.Nodes); hps.GapResolution(); // TODO: add all guessed code to image map -- clearly labelled. } }