public IntPtr ScanMinimum(SigCollection collection) { var results = ScanAll(collection); if (results.Count() == 0) { return(IntPtr.Zero); } return((IntPtr)results.ConvertAll <long>(x => x.ToInt64()).Min()); }
public IntPtr Scan(SigCollection collection) { foreach (Signature sig in collection.Signatures) { IntPtr output = Scan(sig); if (output == IntPtr.Zero) { continue; } if (collection.EvaluateMatch(output)) { return(output); } } return(IntPtr.Zero); }
public static void TestCollectionScan() { byte[] bytes = new byte[] { 0x10, 0x31, 0x20, 0x5C, 0x78, 0x01, 0x10, }; SigCollection sc = new SigCollection("20 5C", "10 31"); Signature s = new Signature("10 31 47"); SigScanner scanner = new SigScanner(bytes); /* * Stopwatch sw = new Stopwatch(); * sw.Start(); * for (int i = 0; i <= 0x5000; i++) * { * scanner.ScanMinimum(sc); * } * * WriteLine(sw.ElapsedMilliseconds); */ WriteLine(scanner.Scan(sc)); ReadLine(); }
public List <IntPtr> ScanAll(SigCollection collection) { List <IntPtr> output = new List <IntPtr>(); foreach (Signature sig in collection.Signatures) { var list = ScanAll(sig); if (list.Count() == 0) { continue; } foreach (IntPtr match in list) { if (collection.EvaluateMatch(match)) { output.Add(match); } } } return(output); }