• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Cil.OpCode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Mono.Cecil.Cil.OpCode的典型用法代码示例。如果您正苦于以下问题:C# OpCode类的具体用法?C# OpCode怎么用?C# OpCode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OpCode类属于Mono.Cecil.Cil命名空间,在下文中一共展示了OpCode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: FindInstruction

        private static Instruction FindInstruction(Mono.Collections.Generic.Collection<Instruction> instructions, OpCode opCode, string operand)
        {
            foreach(var ins in instructions)
            {

                if(ins.OpCode.Code == opCode.Code && ins.Operand.ToString() == operand)
                {
                    return ins;
                }
            }
            return null;
        }
开发者ID:chatrat12,项目名称:Prism,代码行数:12,代码来源:HookInjector.cs


示例17: isFallThrough

 public static bool isFallThrough(OpCode opCode)
 {
     switch (opCode.FlowControl) {
     case FlowControl.Call:
         return opCode != OpCodes.Jmp;
     case FlowControl.Cond_Branch:
     case FlowControl.Next:
         return true;
     default:
         return false;
     }
 }
开发者ID:n017,项目名称:NETDeob,代码行数:12,代码来源:Instr.cs


示例18: InjectNewWriter

		void InjectNewWriter(MethodDefinition sendData, ILProcessor processor, out VariableDefinition mswriter, out OpCode binaryWriter)
		{
			var buffer = sendData.Body.Instructions.First(
				x => x.OpCode == OpCodes.Ldsfld
				&& (x.Operand as FieldReference).Name == "buffer"
			);

			while (!(buffer.Next.OpCode == OpCodes.Callvirt
				&& (buffer.Next.Operand as MethodReference).Name == "set_Position"))
			{
				processor.Remove(buffer.Next);
			}
			processor.Remove(buffer.Next);
			//processor.Remove(buffer);

			//VariableDefinition mswriter;
			sendData.Body.Variables.Add(mswriter = new VariableDefinition("mswriter",
				this.SourceDefinition.MainModule.Import(typeof(MemoryStream))
			));

			var res = processor.InsertBefore(buffer.Previous.Previous,
				new
				{
					OpCodes.Newobj,
					Operand = this.SourceDefinition.MainModule.Import(typeof(MemoryStream)
						.GetConstructors()
						.Single(x => x.GetParameters().Count() == 0)
					)
				},
				new { OpCodes.Stloc, Operand = mswriter },
				new { OpCodes.Ldloc, Operand = mswriter }
			);

			buffer.Previous.Previous.ReplaceTransfer(res[0], sendData);
			processor.Remove(buffer.Previous);
			processor.Remove(buffer.Previous);

			buffer.OpCode = OpCodes.Newobj;
			buffer.Operand = this.SourceDefinition.MainModule.Import(typeof(BinaryWriter)
				.GetConstructors()
				.Single(x => x.GetParameters().Count() == 1)
			);
			if (buffer.Next.OpCode != OpCodes.Ldloc_1)
			{
				throw new NotSupportedException("Expected Ldloc_1");
			}

			/*var*/
			binaryWriter = buffer.Next.OpCode;
			processor.InsertAfter(buffer,
				new { OpCodes.Stloc_1 }
			);
		}
开发者ID:DeathCradle,项目名称:Open-Terraria-API,代码行数:53,代码来源:ReplaceWriter.cs


示例19: TryGetOpCode

        public bool TryGetOpCode(AstNode node, OpCode[] opCodes, out Instruction instruction) {
            List<ILRange> ilRanges = node.Annotation<List<ILRange>>();

            instruction = null;

            foreach (var opCode in opCodes) {
                if (TryGetInstruction(ilRanges, opCode, out instruction)) {
                    return true;
                }
            }

            return false;
        }
开发者ID:sagifogel,项目名称:NJection.LambdaConverter,代码行数:13,代码来源:InstructionsIndexer.cs


示例20: ImplementProceed

            protected override void ImplementProceed(MethodDefinition methodInfo, MethodBody methodBody, ILProcessor il, FieldReference methodInfoField, MethodReference proceed, Action<ILProcessor> emitProceedTarget, MethodReference proceedTargetMethod, OpCode proceedOpCode)
            {
                // If T is an interface, then we want to check if target is null; if so, we want to just return the default value
                var targetNotNull = il.Create(OpCodes.Nop);
                EmitProxyFromProceed(il);
                il.Emit(OpCodes.Ldfld, ClassWeaver.Target);  // Load "target" from "this"
                il.Emit(OpCodes.Brtrue, targetNotNull);      // If target is not null, jump below
                CecilExtensions.CreateDefaultMethodImplementation(methodBody.Method, il);

                il.Append(targetNotNull);                    // Mark where the previous branch instruction should jump to                        

                base.ImplementProceed(methodInfo, methodBody, il, methodInfoField, proceed, emitProceedTarget, proceedTargetMethod, proceedOpCode);
            }
开发者ID:kswoll,项目名称:sexy-proxy,代码行数:13,代码来源:InterfaceClassWeaver.cs



注:本文中的Mono.Cecil.Cil.OpCode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Cil.VariableDefinition类代码示例发布时间:2022-05-26
下一篇:
C# Cil.MethodSymbols类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap