public bool Match(IILReader reader, bool skinNops = true) { if (lastReader != reader) { ResetCore(); } return(matchFunc(Reset() + 1, GetElements(reader, skinNops))); }
public static string GetMethodAsString(MethodBase method) { StringBuilder stb = new StringBuilder(); IILReader reader = ILReaderFactory.GetReader(method); foreach (ILInstruction ili in reader) { stb.AppendLine(ili.ToShortString()); } return(stb.ToString()); }
public override void GetData(object method, Stream outgoingData) { if (method != null) { MethodBodyInfo info = new MethodBodyInfo(); info.TypeName = method.GetType().Name; info.MethodToString = method.ToString(); IILReader reader = ILReaderFactory.GetReader(method); foreach (ILInstruction instr in reader) { info.Instructions.Add(instr.ToString()); } info.FixupSuccess = true; BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(outgoingData, info); } }
void LoadImage(IILReader ILReader) { imgBox.Image = LoadImage("method"); if (ILReader == null) { return; } var methodDesc = ILReader.Metadata.FirstOrDefault(); if (methodDesc != null) { if (methodDesc.Name.Contains(".ctor")) { imgBox.Image = LoadImage("constructor"); } if (methodDesc.Name.Contains("dynamic")) { imgBox.Image = LoadImage("dynmethod"); } } }
IInstruction[] GetElements(IILReader reader, bool skinNops) { lastReader = reader; return((skinNops ? reader.Where(i => i.OpCode != OpCodes.Nop) : reader).ToArray()); }