当前位置: 首页>>代码示例>>C#>>正文


C# Emit.OpCode类代码示例

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


OpCode类属于dnlib.DotNet.Emit命名空间,在下文中一共展示了OpCode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IsFallThrough

		static public 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:RafaelRMachado,项目名称:de4dot,代码行数:11,代码来源:Instr.cs

示例2: IsUnconditionalBranch

		public static bool IsUnconditionalBranch(OpCode opcode)
		{
			if (opcode.OpCodeType == OpCodeType.Prefix)
				return false;
			switch (opcode.FlowControl) {
				case FlowControl.Branch:
				case FlowControl.Throw:
				case FlowControl.Return:
					return true;
				default:
					return false;
			}
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:13,代码来源:OpCodeInfo.cs

示例3: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			var name = field.Name.String;
			callOpcode = OpCodes.Call;
			if (name.EndsWith("%", StringComparison.Ordinal)) {
				callOpcode = OpCodes.Callvirt;
				name = name.TrimEnd(new char[] { '%' });
			}
			byte[] value = Convert.FromBase64String(name);
			int methodIndex = BitConverter.ToInt32(value, 0);	// 0-based memberRef index
			var mr = module.ResolveMemberRef((uint)methodIndex + 1);
			if (mr == null || !mr.IsMethodRef)
				throw new ApplicationException(string.Format("Invalid MemberRef index: {0}", methodIndex));
			calledMethod = mr;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:14,代码来源:ProxyCallFixer.cs

示例4: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			var ctx = (Context)context;

			switch (ctx.proxyCreatorType) {
			case ProxyCreatorType.CallOrCallvirt:
				callOpcode = field.IsFamilyOrAssembly ? OpCodes.Callvirt : OpCodes.Call;
				break;
			case ProxyCreatorType.CallCtor:
				callOpcode = OpCodes.Call;
				break;
			case ProxyCreatorType.Newobj:
				callOpcode = OpCodes.Newobj;
				break;
			default:
				throw new ApplicationException(string.Format("Invalid proxy creator type: {0}", ctx.proxyCreatorType));
			}

			calledMethod = module.ResolveToken(ctx.methodToken) as IMethod;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:19,代码来源:ProxyCallFixer.cs

示例5: GetCallInfo

		protected override void GetCallInfo(object context, FieldDef field, out IMethod calledMethod, out OpCode callOpcode) {
			callOpcode = OpCodes.Call;
			string name = field.Name.String;

			uint memberRefRid = 0;
			for (int i = name.Length - 1; i >= 0; i--) {
				char c = name[i];
				if (c == '~') {
					callOpcode = OpCodes.Callvirt;
					break;
				}

				int val;
				if (specialCharsDict.TryGetValue(c, out val))
					memberRefRid = memberRefRid * (uint)specialChars.Length + (uint)val;
			}
			memberRefRid++;

			calledMethod = module.ResolveMemberRef(memberRefRid);
			if (calledMethod == null)
				Logger.w("Ignoring invalid method RID: {0:X8}, field: {1:X8}", memberRefRid, field.MDToken.ToInt32());
		}
开发者ID:GreenDamTan,项目名称:de4dot,代码行数:22,代码来源:ProxyCallFixer.cs

示例6: GetOpCodeDocumentation

		public static string GetOpCodeDocumentation(OpCode code) {
			int index = (int)code.Code;
			int hi = index >> 8;
			if (hi == 0xFE)
				index -= 0xFD00;
			else if (hi != 0)
				return null;
			var s = cachedOpCodeDocs[index];
			if (s != null)
				return s;

			var docProvider = XmlDocLoader.MscorlibDocumentation;
			if (docProvider != null) {
				string docXml = docProvider.GetDocumentation("F:System.Reflection.Emit.OpCodes." + code.Code.ToString());
				if (docXml != null) {
					XmlDocRenderer renderer = new XmlDocRenderer();
					renderer.AddXmlDocumentation(docXml);
					return cachedOpCodeDocs[index] = renderer.ToString();
				}
			}

			return null;
		}
开发者ID:manojdjoshi,项目名称:dnSpy,代码行数:23,代码来源:ILLanguageHelper.cs

示例7: GetFlippedBranchOpCode

		public bool GetFlippedBranchOpCode(out OpCode opcode) {
			switch (OpCode.Code) {
			case Code.Bge:		opcode = OpCodes.Blt; return true;
			case Code.Bge_S:	opcode = OpCodes.Blt_S; return true;
			case Code.Bge_Un:	opcode = OpCodes.Blt_Un; return true;
			case Code.Bge_Un_S: opcode = OpCodes.Blt_Un_S; return true;

			case Code.Blt:		opcode = OpCodes.Bge; return true;
			case Code.Blt_S:	opcode = OpCodes.Bge_S; return true;
			case Code.Blt_Un:	opcode = OpCodes.Bge_Un; return true;
			case Code.Blt_Un_S: opcode = OpCodes.Bge_Un_S; return true;

			case Code.Bgt:		opcode = OpCodes.Ble; return true;
			case Code.Bgt_S:	opcode = OpCodes.Ble_S; return true;
			case Code.Bgt_Un:	opcode = OpCodes.Ble_Un; return true;
			case Code.Bgt_Un_S: opcode = OpCodes.Ble_Un_S; return true;

			case Code.Ble:		opcode = OpCodes.Bgt; return true;
			case Code.Ble_S:	opcode = OpCodes.Bgt_S; return true;
			case Code.Ble_Un:	opcode = OpCodes.Bgt_Un; return true;
			case Code.Ble_Un_S: opcode = OpCodes.Bgt_Un_S; return true;

			case Code.Brfalse:	opcode = OpCodes.Brtrue; return true;
			case Code.Brfalse_S:opcode = OpCodes.Brtrue_S; return true;

			case Code.Brtrue:	opcode = OpCodes.Brfalse; return true;
			case Code.Brtrue_S: opcode = OpCodes.Brfalse_S; return true;

			// Can't flip beq and bne.un since it's object vs uint/float
			case Code.Beq:
			case Code.Beq_S:
			case Code.Bne_Un:
			case Code.Bne_Un_S:
			default:
				opcode = OpCodes.Nop;	// Whatever...
				return false;
			}
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:38,代码来源:Instr.cs

示例8: FindInstruction

		static int FindInstruction(IList<Instruction> instrs, int index, OpCode opcode) {
			if (index < 0)
				return -1;
			for (int i = index; i < instrs.Count; i++) {
				if (instrs[i].OpCode == opcode)
					return i;
			}
			return -1;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:9,代码来源:StringDecrypter.cs

示例9: Get

		public static OpCodeInfo Get(OpCode opCode)
		{
			return Get(opCode.Code);
		}
开发者ID:modulexcite,项目名称:ICSharpCode.Decompiler-retired,代码行数:4,代码来源:OpCodeInfo.cs

示例10: ConvertOpCode

 ROpCode ConvertOpCode(OpCode opcode)
 {
     ROpCode ropcode;
     if (dnlibToReflection.TryGetValue(opcode, out ropcode))
         return ropcode;
     return ROpCodes.Nop;
 }
开发者ID:kakkerlakgly,项目名称:de4dot,代码行数:7,代码来源:CodeGenerator.cs

示例11: CreateDNLibOperand

			object CreateDNLibOperand(OpCode opcode, Value op) {
				if (op is Int32Value)
					return ((Int32Value)op).Value;
				if (op is StringValue)
					return ((StringValue)op).value;
				return null;
			}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:7,代码来源:StringDecrypter.cs

示例12: InverseBranch

 static OpCode InverseBranch(OpCode opCode)
 {
     switch (opCode.Code) {
         case Code.Bge:
             return OpCodes.Blt;
         case Code.Bge_Un:
             return OpCodes.Blt_Un;
         case Code.Blt:
             return OpCodes.Bge;
         case Code.Blt_Un:
             return OpCodes.Bge_Un;
         case Code.Bgt:
             return OpCodes.Ble;
         case Code.Bgt_Un:
             return OpCodes.Ble_Un;
         case Code.Ble:
             return OpCodes.Bgt;
         case Code.Ble_Un:
             return OpCodes.Bgt_Un;
         case Code.Brfalse:
             return OpCodes.Brtrue;
         case Code.Brtrue:
             return OpCodes.Brfalse;
         case Code.Beq:
             return OpCodes.Bne_Un;
         case Code.Bne_Un:
             return OpCodes.Beq;
     }
     throw new NotSupportedException();
 }
开发者ID:huoxudong125,项目名称:ConfuserEx,代码行数:30,代码来源:SwitchMangler.cs

示例13: AddOperand

        public static void AddOperand(IList<short> instrs, ModuleDefMD module, uint offset, OpCode opCode, object operand)
        {
            Instruction target;
            IVariable variable;
            switch (opCode.OperandType) {
            case OperandType.InlineBrTarget:
                target = operand as Instruction;
                if (target == null)
                    instrs.AddUnknownInt32();
                else
                    instrs.AddInt32(unchecked((int)target.Offset - (int)(offset + 4)));
                break;

            case OperandType.InlineField:
            case OperandType.InlineMethod:
            case OperandType.InlineTok:
            case OperandType.InlineType:
                var tok = operand as ITokenOperand;
                instrs.AddToken(module, tok == null ? 0 : tok.MDToken.Raw);
                break;

            case OperandType.InlineSig:
                var msig = operand as MethodSig;
                instrs.AddToken(module, msig == null ? 0 : msig.OriginalToken);
                break;

            case OperandType.InlineString:
                instrs.AddUnknownInt32();
                break;

            case OperandType.InlineI:
                if (operand is int)
                    instrs.AddInt32((int)operand);
                else
                    instrs.AddUnknownInt32();
                break;

            case OperandType.InlineI8:
                if (operand is long)
                    instrs.AddInt64((long)operand);
                else
                    instrs.AddUnknownInt64();
                break;

            case OperandType.InlineR:
                if (operand is double)
                    instrs.AddDouble((double)operand);
                else
                    instrs.AddUnknownInt64();
                break;

            case OperandType.ShortInlineR:
                if (operand is float)
                    instrs.AddSingle((float)operand);
                else
                    instrs.AddUnknownInt32();
                break;

            case OperandType.InlineSwitch:
                var targets = operand as IList<Instruction>;
                if (targets == null)
                    instrs.AddUnknownInt32();
                else {
                    uint offsetAfter = offset + 4 + (uint)targets.Count * 4;
                    instrs.AddInt32(targets.Count);
                    foreach (var instr in targets) {
                        if (instr == null)
                            instrs.AddUnknownInt32();
                        else
                            instrs.AddInt32(unchecked((int)instr.Offset - (int)offsetAfter));
                    }
                }
                break;

            case OperandType.InlineVar:
                variable = operand as IVariable;
                if (variable == null)
                    instrs.AddUnknownInt16();
                else if (ushort.MinValue <= variable.Index && variable.Index <= ushort.MaxValue)
                    instrs.AddInt16(unchecked((short)variable.Index));
                else
                    instrs.AddUnknownInt16();
                break;

            case OperandType.ShortInlineVar:
                variable = operand as IVariable;
                if (variable == null)
                    instrs.AddUnknownByte();
                else if (byte.MinValue <= variable.Index && variable.Index <= byte.MaxValue)
                    instrs.Add((byte)variable.Index);
                else
                    instrs.AddUnknownByte();
                break;

            case OperandType.ShortInlineBrTarget:
                target = operand as Instruction;
                if (target == null)
                    instrs.AddUnknownByte();
                else {
                    int displ = unchecked((int)target.Offset - (int)(offset + 1));
//.........这里部分代码省略.........
开发者ID:BahNahNah,项目名称:dnSpy,代码行数:101,代码来源:InstructionUtils.cs

示例14: Add

		protected void Add(MethodDef oldMethod, IMethod newMethod, OpCode opCode) {
			if (oldMethod == null)
				return;
			oldToNewMethod.Add(oldMethod, new NewMethodInfo(opCode, newMethod));
		}
开发者ID:GodLesZ,项目名称:de4dot,代码行数:5,代码来源:MethodCallRestorerBase.cs

示例15: create

 static Instruction create(OpCode opcode, object operand)
 {
     return new Instruction {
         OpCode = opcode,
         Operand = operand,
     };
 }
开发者ID:n017,项目名称:ConfuserDeobfuscator,代码行数:7,代码来源:MethodsRewriter.cs


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