當前位置: 首頁>>代碼示例>>C#>>正文


C# Cil.OpCode類代碼示例

本文整理匯總了C#中Mono.Cecil.Cil.OpCode的典型用法代碼示例。如果您正苦於以下問題:C# OpCode類的具體用法?C# OpCode怎麽用?C# OpCode使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


OpCode類屬於Mono.Cecil.Cil命名空間,在下文中一共展示了OpCode類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ReadSigKey

 public static bool ReadSigKey(MethodDefinition DecryptMethod, OpCode[] KeySig, ref object val)
 {
     int score = 0;
     for (int i = 0; i < DecryptMethod.Body.Instructions.Count; i++)
     {
         if (DecryptMethod.Body.Instructions[i].OpCode == KeySig[score])
         {
             score++;
             if (score == KeySig.Length)
             {
                 if (DecryptMethod.Body.Instructions[i].Next != null)
                 {
                     if (DecryptMethod.Body.Instructions[i].Next.Operand != null)
                     {
                         val = DecryptMethod.Body.Instructions[i].Next.Operand;
                         return true;
                     }
                 }
             }
         }
         else
         {
             score = 0;
         }
     }
     return false;
 }
開發者ID:KenMacD,項目名稱:deconfuser,代碼行數:27,代碼來源:Program.cs

示例2: Create

		public Instruction Create (OpCode opcode)
		{
			if (opcode.OperandType != OperandType.InlineNone)
				throw new ArgumentException ("opcode");

			return FinalCreate (opcode);
		}
開發者ID:transformersprimeabcxyz,項目名稱:monodevelop-1,代碼行數:7,代碼來源:CilWorker.cs

示例3: TryGetInstruction

        private bool TryGetInstruction(List<ILRange> ilRanges, OpCode opCode, out Instruction instruction) {
            int fromOffset = 0;
            int toOffset = 0;

            if (ilRanges == null || ilRanges.Count == 0) {
                instruction = null;
                return false;
            }

            fromOffset = ilRanges[0].From;
            toOffset = ilRanges[0].To;
            instruction = InstructionAt(fromOffset);

            do {
                if (instruction.OpCode == opCode) {
                    return true;
                }

                instruction = instruction.Next;
                fromOffset = instruction.Offset;
            }
            while (fromOffset != toOffset);

            return instruction.OpCode == opCode;
        }
開發者ID:sagifogel,項目名稱:NJection.LambdaConverter,代碼行數:25,代碼來源:InstructionsIndexer.cs

示例4: SimplifyOpCode

 /// <summary>
 /// 
 /// </summary>
 /// <param name="toSimplify"></param>
 /// <returns></returns>
 private static OpCode SimplifyOpCode(OpCode toSimplify)
 {
     switch (toSimplify.Code) {
         case Code.Br_S:
             return OpCodes.Br;
         case Code.Brfalse_S:
             return OpCodes.Brfalse;
         case Code.Brtrue_S:
             return OpCodes.Brtrue;
         case Code.Beq_S:
             return OpCodes.Beq;
         case Code.Bge_S:
             return OpCodes.Bge;
         case Code.Bgt_S:
             return OpCodes.Bgt;
         case Code.Ble_S:
             return OpCodes.Ble;
         case Code.Blt_S:
             return OpCodes.Blt;
         case Code.Bne_Un_S:
             return OpCodes.Bne_Un;
         case Code.Bge_Un_S:
             return OpCodes.Bge_Un;
         case Code.Bgt_Un_S:
             return OpCodes.Bgt_Un;
         case Code.Ble_Un_S:
             return OpCodes.Ble_Un;
         case Code.Blt_Un_S:
             return OpCodes.Blt_Un;
         case Code.Leave_S:
             return OpCodes.Leave;
         default:
             return toSimplify;
     }
 }
開發者ID:GregRos,項目名稱:Patchwork,代碼行數:40,代碼來源:FixReferences.cs

示例5: FindInstruction

		public static Instruction FindInstruction(AssemblyDefinition assembly, string typeName, string testMethodName, OpCode testInstruction)
		{
			MethodDefinition testMethod = FindMethod(assembly, typeName, testMethodName);
			Assert.IsNotNull(testMethod);

			return FindInstruction(testMethod, testInstruction);
		}
開發者ID:erdincay,項目名稱:db4o,代碼行數:7,代碼來源:ReflectionServices.cs

示例6: AssertInstruction

		internal static void AssertInstruction(Instruction actual, OpCode opCode, MemberReference expectedCtor)
		{
			Assert.AreEqual(opCode, actual.OpCode);
			MethodReference actualCtor = (MethodReference)actual.Operand;
			Assert.AreEqual(expectedCtor.DeclaringType.Name, actualCtor.DeclaringType.Name, opCode.ToString());
			Assert.AreEqual(expectedCtor, actualCtor.Resolve(), opCode.ToString());
		}
開發者ID:bvangrinsven,項目名稱:db4o-net,代碼行數:7,代碼來源:TACollectionsTestCaseBase.cs

示例7: GetNegativeModifier

 private static int GetNegativeModifier(OpCode opCode)
 {
     switch (opCode.StackBehaviourPop)
     {
         case StackBehaviour.Pop0:
             return 0;
         case StackBehaviour.Pop1:
         case StackBehaviour.Popi:
         case StackBehaviour.Popref:
         case StackBehaviour.Varpop:
             return 1;
         case StackBehaviour.Pop1_pop1:
         case StackBehaviour.Popi_pop1:
         case StackBehaviour.Popi_popi:
         case StackBehaviour.Popi_popi8:
         case StackBehaviour.Popi_popr4:
         case StackBehaviour.Popi_popr8:
         case StackBehaviour.Popref_pop1:
         case StackBehaviour.Popref_popi:
             return 2;
         case StackBehaviour.Popi_popi_popi:
         case StackBehaviour.Popref_popi_popi:
         case StackBehaviour.Popref_popi_popi8:
         case StackBehaviour.Popref_popi_popr4:
         case StackBehaviour.Popref_popi_popr8:
         case StackBehaviour.Popref_popi_popref:
             return 3;
         case StackBehaviour.PopAll:
             return 1000;
     }
     return 0;
 }
開發者ID:Cadla,項目名稱:OBFSCTR,代碼行數:32,代碼來源:MethodCallStackFrame.cs

示例8: CreateTestAssembly

        private static AssemblyDefinition CreateTestAssembly(OpCode arithmeticOperator)
        {
            var name = new AssemblyNameDefinition("TestBitwiseOperatorTurtleOr", new Version(1, 0));
            var assembly = AssemblyDefinition.CreateAssembly(name, "TestClass", ModuleKind.Dll);
            var type = new TypeDefinition("TestBitwiseOperatorTurtleOr", "TestClass",
                               TypeAttributes.Class | TypeAttributes.Public);
            var intType = assembly.MainModule.Import(typeof(int));
            var method = new MethodDefinition("TestMethod", MethodAttributes.Public, intType);
            var leftParam = new ParameterDefinition("left", ParameterAttributes.In, intType);
            var rightParam = new ParameterDefinition("right", ParameterAttributes.In, intType);
            method.Parameters.Add(leftParam);
            method.Parameters.Add(rightParam);
            var resultVariable = new VariableDefinition(intType);
            method.Body.Variables.Add(resultVariable);

            var processor = method.Body.GetILProcessor();
            method.Body.Instructions.Add(processor.Create(OpCodes.Ldarg, leftParam));
            method.Body.Instructions.Add(processor.Create(OpCodes.Ldarg, rightParam));
            method.Body.Instructions.Add(processor.Create(arithmeticOperator));
            method.Body.Instructions.Add(processor.Create(OpCodes.Stloc, resultVariable));
            method.Body.Instructions.Add(processor.Create(OpCodes.Ldloc, resultVariable));
            method.Body.Instructions.Add(processor.Create(OpCodes.Ret));

            type.Methods.Add(method);
            assembly.MainModule.Types.Add(type);
            return assembly;
        }
開發者ID:dbremner,項目名稱:ninjaturtles,代碼行數:27,代碼來源:BitwiseOperatorTurtleTests.cs

示例9: CreateTestAssembly

        private static AssemblyDefinition CreateTestAssembly(OpCode opCode, bool invert)
        {
            var name = new AssemblyNameDefinition("TestConditionalsBoundaryTurtle", new Version(1, 0));
            var assembly = AssemblyDefinition.CreateAssembly(name, "TestClass", ModuleKind.Dll);
            var type = new TypeDefinition("TestConditionalsBoundaryTurtle", "TestClass",
                               TypeAttributes.Class | TypeAttributes.Public);
            var intType = assembly.MainModule.Import(typeof(int));
            var boolType = assembly.MainModule.Import(typeof(bool));
            var method = new MethodDefinition("TestMethod", MethodAttributes.Public, intType);
            var param = new ParameterDefinition("input", ParameterAttributes.In, intType);
            method.Parameters.Add(param);
            var resultVariable = new VariableDefinition(boolType);
            method.Body.Variables.Add(resultVariable);

            var processor = method.Body.GetILProcessor();
            Instruction loadReturnValueInstruction = processor.Create(OpCodes.Ldloc, resultVariable);
            method.Body.Instructions.Add(processor.Create(OpCodes.Ldarg, param));
            method.Body.Instructions.Add(processor.Create(OpCodes.Ldc_I4, 0));
            method.Body.Instructions.Add(processor.Create(opCode));
            if (invert)
            {
                method.Body.Instructions.Add(processor.Create(OpCodes.Ldc_I4, 0));
                method.Body.Instructions.Add(processor.Create(OpCodes.Ceq));
            }
            method.Body.Instructions.Add(processor.Create(OpCodes.Stloc, resultVariable));
            method.Body.Instructions.Add(loadReturnValueInstruction);
            method.Body.Instructions.Add(processor.Create(OpCodes.Ret));

            type.Methods.Add(method);
            assembly.MainModule.Types.Add(type);
            return assembly;
        }
開發者ID:dbremner,項目名稱:ninjaturtles,代碼行數:32,代碼來源:ConditionalBoundaryTurtleTests.cs

示例10: Create

        public static Instruction Create(OpCode opcode)
        {
            if (opcode.OperandType != OperandType.InlineNone)
                throw new ArgumentException ("opcode");

            return new Instruction (opcode, null);
        }
開發者ID:mono,項目名稱:cecil,代碼行數:7,代碼來源:Instruction.cs

示例11: AssertOpCodeSequence

		static void AssertOpCodeSequence (OpCode [] expected, MethodBody body)
		{
			var opcodes = body.Instructions.Select (i => i.OpCode).ToArray ();
			Assert.AreEqual (expected.Length, opcodes.Length);

			for (int i = 0; i < opcodes.Length; i++)
				Assert.AreEqual (expected [i], opcodes [i]);
		}
開發者ID:0xb1dd1e,項目名稱:cecil,代碼行數:8,代碼來源:ILProcessorTests.cs

示例12: Create

		public Instruction Create (OpCode opcode, FieldReference field)
		{
			if (opcode.OperandType != OperandType.InlineField &&
				opcode.OperandType != OperandType.InlineTok)
				throw new ArgumentException ("opcode");

			return FinalCreate (opcode, field);
		}
開發者ID:pusp,項目名稱:o2platform,代碼行數:8,代碼來源:CilWorker.cs

示例13: PatternInstruction

 public PatternInstruction(OpCode[] eligibleOpCodes, Terminal terminal = null, Predicate predicate = null) {
     if (eligibleOpCodes == null)
         throw new ArgumentNullException(Name.Of(eligibleOpCodes));
     if (eligibleOpCodes.Length == 0)
         throw new ArgumentException("Array length must be greater than zero", Name.Of(eligibleOpCodes));
     EligibleOpCodes = eligibleOpCodes;
     Terminal = terminal;
     this.predicate = predicate ?? PredicateDummy;
 }
開發者ID:Kleptine,項目名稱:NameOf,代碼行數:9,代碼來源:PatternInstruction.cs

示例14: isAnotherPath

        private bool isAnotherPath(OpCode opCode)
        {
            if (opCode.FlowControl == FlowControl.Branch)
                return true;

            if (opCode.Code == Code.Jmp)
                return true;

            return false;
        }
開發者ID:neelendu,項目名稱:DrivenMetrics,代碼行數:10,代碼來源:CyclomicComplextityCalculator.cs

示例15: Create

		public Instruction Create (OpCode opcode, byte value)
		{
			if (opcode.OperandType == OperandType.ShortInlineVar)
				return Instruction.Create (opcode, body.Variables [value]);

			if (opcode.OperandType == OperandType.ShortInlineArg)
				return Instruction.Create (opcode, body.GetParameter (value));

			return Instruction.Create (opcode, value);
		}
開發者ID:0xb1dd1e,項目名稱:cecil,代碼行數:10,代碼來源:ILProcessor.cs


注:本文中的Mono.Cecil.Cil.OpCode類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。