public DisassembleNextInstruction ( ) : |
||
리턴 |
public virtual x86Instruction DisassembleNextInstruction()
{
x86Instruction newInstruction = new x86Instruction();
newInstruction.Offset = Offset.FromFileOffset((uint)reader.BaseStream.Position, assembly) ;
newInstruction.OpCode = RetrieveNextOpCode();
ProcessVariableByteIndex(ref newInstruction.code);
ProcessRegisterOperands(newInstruction);
byte[] rawOperand = ReadRawOperand(newInstruction.OpCode);
newInstruction.operandbytes = ASMGlobals.MergeBytes(newInstruction.operandbytes, rawOperand);
ProcessOperandBytes(newInstruction);
ProcessOverrideOperand(newInstruction);
return newInstruction;
}
/// <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); }