namespace X86Disassembler.X86.Handlers; /// /// Base class for all instruction handlers /// public abstract class InstructionHandler { // Buffer containing the code to decode protected readonly byte[] CodeBuffer; // The instruction decoder that owns this handler protected readonly InstructionDecoder Decoder; // Length of the buffer protected readonly int Length; // ModRM decoder for handling addressing modes protected readonly ModRMDecoder ModRMDecoder; /// /// Initializes a new instance of the InstructionHandler class /// /// The buffer containing the code to decode /// The instruction decoder that owns this handler /// The length of the buffer protected InstructionHandler(byte[] codeBuffer, InstructionDecoder decoder, int length) { CodeBuffer = codeBuffer; Decoder = decoder; Length = length; ModRMDecoder = new ModRMDecoder(codeBuffer, decoder, length); } /// /// Checks if this handler can decode the given opcode /// /// The opcode to check /// True if this handler can decode the opcode public abstract bool CanHandle(byte opcode); /// /// Decodes an instruction /// /// The opcode of the instruction /// The instruction object to populate /// True if the instruction was successfully decoded public abstract bool Decode(byte opcode, Instruction instruction); }