Created
February 5, 2017 13:37
-
-
Save ioncodes/66ef855e5719373a7c22c2cf84b9e8cb to your computer and use it in GitHub Desktop.
Get's the calls in a method and adds them to a list. Uses dnlib.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static List<string[]> GetReferences(ModuleDef module) | |
{ | |
var typeSet = new HashSet<string>(); | |
foreach (var type in module.Types) | |
{ | |
typeSet.Add(type.Name); | |
} | |
var refs = (from type in module.Types from method in type.Methods where method.HasBody from instruction in method.Body.Instructions where instruction.OpCode == OpCodes.Call from set in typeSet where type.Name != set where instruction.Operand.ToString().Contains(set) select new string[] {type.Name, set}).ToList(); | |
return refs.GroupBy(strArr => string.Join("|", strArr)) | |
.Select(g => g.First()) | |
.ToList(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment