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


C# Instruction.GetSize方法代码示例

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

在下文中一共展示了Instruction.GetSize方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ReadOneInstruction_Special

        protected Instruction ReadOneInstruction_Special(VirtualOpCode virtualInstruction)
        {
            //this.Logger.Verbose(this, "Special Opcode ({0}, delegate MDToken = 0x{1:X8})",
            //	virtualInstruction.SpecialOpCode.ToString(),
            //	virtualInstruction.DelegateMethod.MDToken.Raw
            //);

            // Have a method for this?
            OpCode opcode = null;
            switch(virtualInstruction.SpecialOpCode)
            {
                case SpecialCode.Eaz_Call:
                    opcode = Code.Call.ToOpCode(); // Or Callvirt?
                    break;
            }

            if(opcode == null)
            {
                throw new Exception(String.Format(
                    "Cannot convert SpecialOpCode to CIL OpCode: {0}",
                    virtualInstruction.SpecialOpCode
                ));
            }

            Object operand = this.ReadSpecialOperand(virtualInstruction);

            Instruction instruction = new Instruction(opcode);
            instruction.Offset = this.CurrentILOffset;
            instruction.OpCode = opcode;
            instruction.Operand = operand; // this.ReadOperand(instruction);

            this.CurrentILOffset += (UInt32)instruction.GetSize();
            this.CurrentVirtualOffset += (UInt32)virtualInstruction.GetSize(instruction.Operand);

            this.CurrentInstructionOffset++;

            return instruction;
        }
开发者ID:3H54N,项目名称:eazdevirt,代码行数:38,代码来源:VirtualizedMethodBodyReader.cs


示例2: ResolveOffset

 private static int ResolveOffset(CilBody body, Instruction instruction)
 {
     if (instruction == null)
     {
         instruction = body.Instructions[body.Instructions.Count - 1];
         return (int)(instruction.Offset + instruction.GetSize());
     }
     else
         return (int)instruction.Offset;
 }
开发者ID:pacificIT,项目名称:MOSA-Project,代码行数:10,代码来源:MetadataResolver.cs


示例3: GetInstructionSize

 protected static int GetInstructionSize(Instruction instr)
 {
     var opcode = instr.OpCode;
     if (opcode == null)
         return 5;	// Load store/field
     var op = instr.Operand as SwitchTargetDisplOperand;
     if (op == null)
         return instr.GetSize();
     return instr.OpCode.Size + (op.TargetDisplacements.Length + 1) * 4;
 }
开发者ID:kakkerlakgly,项目名称:de4dot,代码行数:10,代码来源:CsvmToCilMethodConverterBase.cs


示例4: ReadOneInstruction_CIL

        protected Instruction ReadOneInstruction_CIL(VirtualOpCode virtualInstruction)
        {
            OpCode opcode = virtualInstruction.OpCode.ToOpCode();

            Instruction instruction = new Instruction(opcode);
            instruction.Offset = this.CurrentILOffset;
            instruction.OpCode = opcode;
            instruction.Operand = this.ReadOperand(instruction);

            if (instruction.OpCode.Code == Code.Switch)
            {
                var targets = (IList<UInt32>)instruction.Operand;
                this.CurrentILOffset += (UInt32)(instruction.OpCode.Size + 4 + (4 * targets.Count));
                this.CurrentVirtualOffset += (UInt32)(4 + 4 + (4 * targets.Count));
            }
            else
            {
                this.CurrentILOffset += (UInt32)instruction.GetSize();
                this.CurrentVirtualOffset += (UInt32)virtualInstruction.GetSize(instruction.Operand);
            }

            this.CurrentInstructionOffset++;

            return instruction;
        }
开发者ID:3H54N,项目名称:eazdevirt,代码行数:25,代码来源:VirtualizedMethodBodyReader.cs


示例5: ReadShortInlineBrTarget

		/// <summary>
		/// Reads a <see cref="OperandType.ShortInlineBrTarget"/> operand
		/// </summary>
		/// <param name="instr">The current instruction</param>
		/// <returns>The operand</returns>
		protected virtual uint ReadShortInlineBrTarget(Instruction instr) {
			return instr.Offset + (uint)instr.GetSize() + (uint)reader.ReadSByte();
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:MethodBodyReaderBase.cs


示例6: ReadInlineBrTarget

		/// <summary>
		/// Reads a <see cref="OperandType.InlineBrTarget"/> operand
		/// </summary>
		/// <param name="instr">The current instruction</param>
		/// <returns>The operand</returns>
		protected virtual uint ReadInlineBrTarget(Instruction instr) {
			return instr.Offset + (uint)instr.GetSize() + reader.ReadUInt32();
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:MethodBodyReaderBase.cs


示例7: ReadOneInstruction

		/// <summary>
		/// Reads the next instruction
		/// </summary>
		Instruction ReadOneInstruction() {
			var instr = new Instruction();
			instr.Offset = currentOffset;
			instr.OpCode = ReadOpCode();
			instr.Operand = ReadOperand(instr);

			if (instr.OpCode.Code == Code.Switch) {
				var targets = (IList<uint>)instr.Operand;
				currentOffset += (uint)(instr.OpCode.Size + 4 + 4 * targets.Count);
			}
			else
				currentOffset += (uint)instr.GetSize();
			if (currentOffset < instr.Offset)
				reader.Position = codeEndOffs;
			return instr;
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:19,代码来源:MethodBodyReaderBase.cs


示例8: GetSize

        /// <summary>
        /// Get the size of this virtual instruction. Requires that the instruction be identified
        /// with a CIL opcode.
        /// </summary>
        /// <param name="operand">Instruction operand</param>
        /// <returns>Size of instruction when serialized</returns>
        /// <exception cref="System.Exception">Thrown if virtual instruction not identified</exception>
        public Int32 GetSize(Object operand)
        {
            if (!this.IsIdentified)
                throw new Exception("Cannot get a virtual instruction's size if not identified");

            if (this.HasCILOpCode)
            {
                // Instruction instruction = this.OpCode.ToOpCode().ToInstruction();
                Instruction instruction = new Instruction(this.OpCode.ToOpCode(), operand);
                return (instruction.GetSize() - instruction.OpCode.Size) + 4;
            }
            else
            {
                switch(this.SpecialOpCode)
                {
                    case SpecialCode.Eaz_Call:
                        return 8;
                }

                throw new Exception(String.Format(
                    "Cannot get size of virtual instruction: {0}",
                    this.Name));
            }
        }
开发者ID:3H54N,项目名称:eazdevirt,代码行数:31,代码来源:VirtualOpCode.cs


示例9: GetSizeOfInstruction

		/// <summary>
		/// Gets the size of an instruction
		/// </summary>
		/// <param name="instr">The instruction</param>
		/// <returns>Size of the instruction in bytes</returns>
		protected virtual uint GetSizeOfInstruction(Instruction instr) {
			return (uint)instr.GetSize();
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:8,代码来源:MethodBodyWriterBase.cs



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