Пример #1
0
        private static void ldc2_w(Instruction instruction, Frame frame, ClassFile cFile)
        {
            ushort index = BitConverter.ToUInt16(instruction.Operand, 0);

            frame.PutLongToStack(((CONSTANT_B8_info)cFile.GetConstant(index).Info).ToLong());
            nop(instruction, frame, cFile);
        }
Пример #2
0
        public static void Main(string[] args)
        {
            //byte[] data = File.ReadAllBytes(@"..\..\NOD.class");
            //byte[] data = File.ReadAllBytes(@"..\..\SQRT.class");
            byte[]    data  = File.ReadAllBytes(@"..\..\..\javac\NOD.class");
            ClassFile cFile = ClassFile.ParseClassFile(data);

            // TODO: check cFile.AccessFlags

            MethodInfo methodMain = null;

            foreach (var m in cFile.Methods)
            {
                if (m.AccessFlags != (short)(MethodAccessFlags.ACC_PUBLIC | MethodAccessFlags.ACC_STATIC))
                {
                    continue;
                }
                var mName = (CONSTANT_Utf8_info)cFile.GetConstant(m.NameIndex).Info;
                if (!mName.String.Equals(MAIN_NAME))
                {
                    continue;
                }

                var mSignature = (CONSTANT_Utf8_info)cFile.GetConstant(m.DescriptorIndex).Info;
                if (!mSignature.String.Equals(MAIN_SIGNATURE))
                {
                    continue;
                }

                methodMain = m;
                break;
            }

            if (methodMain == null)
            {
                throw new Exception("Main method is not found!");
            }
            RunMethod(cFile, methodMain, new int[0]);
            Console.ReadLine();
        }
Пример #3
0
 private static void ldc(Instruction instruction, Frame frame, ClassFile cFile)
 {
     frame.Stack.Push(((CONSTANT_B4_info)cFile.GetConstant(instruction.Operand[0]).Info).ToInt());
     nop(instruction, frame, cFile);
 }