Beispiel #1
0
        private AnalysisNet.IInstruction ProcessMethodCall(Cecil.Cil.Instruction op)
        {
            AnalysisNetBytecode.MethodCallOperation operation = OperationHelper.ToMethodCallOperation(op.OpCode.Code);
            Cecil.MethodReference cciMethod = op.Operand as Cecil.MethodReference;
            AnalysisNet.Types.IMethodReference ourMethod = typeExtractor.ExtractMethod(cciMethod);

            AnalysisNet.IInstruction instruction;

            if (ourMethod.ContainingType is FakeArrayType fakeArrayType)
            {
                AnalysisNet.Types.ArrayType arrayType = fakeArrayType.Type;

                if (ourMethod.Name == "Set")
                {
                    instruction = ProcessStoreArrayElement(op, arrayType);
                    return(instruction);
                }
                else
                {
                    AnalysisNetBytecode.LoadArrayElementOperation arrayOp = OperationHelper.ToLoadArrayElementOperation(ourMethod.Name);

                    instruction = ProcessLoadArrayElement(op, arrayOp, arrayType);
                    return(instruction);
                }
            }

            instruction = new AnalysisNetBytecode.MethodCallInstruction((uint)op.Offset, operation, ourMethod);
            return(instruction);
        }
Beispiel #2
0
        private AnalysisNet.IInstruction ProcessLoadArrayElement(Cecil.Cil.Instruction op, AnalysisNetBytecode.LoadArrayElementOperation operation)
        {
            AnalysisNet.Types.ArrayType arrayType = null;

            switch (op.OpCode.Code)
            {
            /*case Mono.Cecil.Cil.Code.Array_Addr:
             * case Mono.Cecil.Cil.Code.Array_Create:
             * case Mono.Cecil.Cil.Code.Array_Create_WithLowerBound:
             * case Mono.Cecil.Cil.Code.Array_Get:
             * case Mono.Cecil.Cil.Code.Array_Set:
             *  arrayType = typeExtractor.ExtractType(op.Operand as Cecil.TypeReference) as ArrayType;
             *  break;*/
            //case Mono.Cecil.Cil.Code.Ldelem:
            case Mono.Cecil.Cil.Code.Ldelem_Any:
            case Mono.Cecil.Cil.Code.Ldelema:
                arrayType = new AnalysisNet.Types.ArrayType(typeExtractor.ExtractType(op.Operand as Cecil.TypeReference));
                break;

            default:
                arrayType = new AnalysisNet.Types.ArrayType(OperationHelper.GetOperationType(op.OpCode.Code));
                break;
            }

            if (arrayType == null)
            {
                throw new NotImplementedException();
            }

            AnalysisNetBytecode.LoadArrayElementInstruction instruction = new AnalysisNetBytecode.LoadArrayElementInstruction((uint)op.Offset, operation, arrayType);
            return(instruction);
        }
Beispiel #3
0
 private AnalysisNet.IInstruction ProcessLoadArrayElement(Cecil.Cil.Instruction op, AnalysisNetBytecode.LoadArrayElementOperation operation, AnalysisNet.Types.ArrayType arrayType = null)
 {
     AnalysisNetBytecode.LoadArrayElementInstruction instruction = new AnalysisNetBytecode.LoadArrayElementInstruction((uint)op.Offset, operation, arrayType);
     return(instruction);
 }