0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-06-20 08:18:36 +03:00

Fix x86 disassembler issues with direct memory addressing and immediate value formatting

This commit is contained in:
bird_egop
2025-04-15 02:29:32 +03:00
parent d351f41808
commit 3ea327064a
67 changed files with 854 additions and 453 deletions

View File

@ -71,7 +71,7 @@ public class XorImmWithRm16SignExtendedHandler : InstructionHandler
short imm16 = (sbyte)Decoder.ReadByte();
// Create the source immediate operand with the sign-extended value
var sourceOperand = OperandFactory.CreateImmediateOperand(imm16, 16);
var sourceOperand = OperandFactory.CreateImmediateOperand((ushort)imm16, 16);
// Set the structured operands
instruction.StructuredOperands =

View File

@ -65,7 +65,7 @@ public class XorImmWithRm32SignExtendedHandler : InstructionHandler
int imm32 = (sbyte)Decoder.ReadByte();
// Create the immediate operand with sign extension
var immOperand = OperandFactory.CreateImmediateOperand(imm32);
var immOperand = OperandFactory.CreateImmediateOperand((uint)imm32);
// Set the structured operands
instruction.StructuredOperands =

View File

@ -47,18 +47,10 @@ public class XorImmWithRm8Handler : InstructionHandler
// Set the instruction type
instruction.Type = InstructionType.Xor;
if (!Decoder.CanReadByte())
{
return false;
}
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
// Read the ModR/M byte
// For XOR r/m8, imm8 (0x80 /6):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The immediate value is the source operand
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
// Adjust the operand size to 8-bit
// Ensure the destination operand has the correct size (8-bit)
destinationOperand.Size = 8;
// Read the immediate value

View File

@ -36,19 +36,11 @@ public class XorR8Rm8Handler : InstructionHandler
{
// Set the instruction type
instruction.Type = InstructionType.Xor;
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM8();
if (!Decoder.CanReadByte())
{
return false;
}
// Read the ModR/M byte
// For XOR r8, r/m8 (0x32):
// - The reg field specifies the destination register
// - The r/m field with mod specifies the source operand (register or memory)
var (mod, reg, rm, sourceOperand) = ModRMDecoder.ReadModRM();
// Adjust the operand size to 8-bit
// Ensure the source operand has the correct size (8-bit)
sourceOperand.Size = 8;
// Create the destination register operand

View File

@ -49,12 +49,9 @@ public class XorRm16R16Handler : InstructionHandler
// Create the source register operand (16-bit)
var sourceOperand = OperandFactory.CreateRegisterOperand(reg, 16);
// For memory operands, we need to adjust the size to 16-bit
if (mod != 3) // Memory addressing mode
{
// Adjust memory operand size to 16-bit
destinationOperand.Size = 16;
}
// For all operands, we need to adjust the size to 16-bit
// This ensures register operands also get the correct size
destinationOperand.Size = 16;
// Set the structured operands
instruction.StructuredOperands =

View File

@ -36,19 +36,11 @@ public class XorRm8R8Handler : InstructionHandler
{
// Set the instruction type
instruction.Type = InstructionType.Xor;
// Read the ModR/M byte, specifying that we're dealing with 8-bit operands
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM8();
if (!Decoder.CanReadByte())
{
return false;
}
// Read the ModR/M byte
// For XOR r/m8, r8 (0x30):
// - The r/m field with mod specifies the destination operand (register or memory)
// - The reg field specifies the source register
var (mod, reg, rm, destinationOperand) = ModRMDecoder.ReadModRM();
// Adjust the operand size to 8-bit
// Ensure the destination operand has the correct size (8-bit)
destinationOperand.Size = 8;
// Create the source register operand