DisassembleNextInstruction() public method

Disassembles the next instruction at the current offset.
public DisassembleNextInstruction ( ) : x86Instruction
return x86Instruction
Ejemplo n.º 1
0
        /// <summary>
        /// Calculates and returns the size in bytes needed when replacing an instruction
        /// </summary>
        /// <param name="targetInstruction">The instruction to be replaced.</param>
        /// <param name="newSize">The new instruction's size.</param>
        /// <returns></returns>
        public int CalculateSpaceNeeded(x86Instruction targetInstruction, int newSize)
        {
            if (newSize <= targetInstruction.Size)
            {
                return(targetInstruction.Size);
            }

            int sizeNeeded = 0;

            uint currentOffset = targetInstruction.Offset.FileOffset;

            while (sizeNeeded < newSize)
            {
                disassembler.CurrentOffset = currentOffset;
                x86Instruction currentInstruction = disassembler.DisassembleNextInstruction();
                sizeNeeded    += currentInstruction.Size;
                currentOffset += (uint)currentInstruction.Size;
            }
            return(sizeNeeded);
        }