Ejemplo n.º 1
0
 public bool Match(IILReader reader, bool skinNops = true)
 {
     if (lastReader != reader)
     {
         ResetCore();
     }
     return(matchFunc(Reset() + 1, GetElements(reader, skinNops)));
 }
Ejemplo n.º 2
0
        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);
            }
        }
Ejemplo n.º 4
0
        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");
                }
            }
        }
Ejemplo n.º 5
0
 IInstruction[] GetElements(IILReader reader, bool skinNops)
 {
     lastReader = reader;
     return((skinNops ? reader.Where(i => i.OpCode != OpCodes.Nop) : reader).ToArray());
 }