0
mirror of https://github.com/sampletext32/ParkanPlayground.git synced 2025-05-19 11:51:17 +03:00

Simplified JmpRel32Handler by improving target address calculation and code organization

This commit is contained in:
bird_egop 2025-04-14 00:11:55 +03:00
parent 38770de005
commit 996be18172

View File

@ -37,20 +37,21 @@ public class JmpRel32Handler : InstructionHandler
// Set the mnemonic // Set the mnemonic
instruction.Mnemonic = "jmp"; instruction.Mnemonic = "jmp";
// Check if we have enough bytes for the offset
int position = Decoder.GetPosition(); int position = Decoder.GetPosition();
if (position + 4 > Length) if (position + 4 > Length)
{ {
return false; return false;
} }
// Read the relative offset // Read the offset and calculate target address
uint offset = Decoder.ReadUInt32(); int offset = (int)Decoder.ReadUInt32();
// Calculate the target address // Calculate target address (instruction address + instruction length + offset)
uint targetAddress = (uint)(position + offset + 4); // For JMP rel32, the instruction is 5 bytes: opcode (1 byte) + offset (4 bytes)
uint targetAddress = (uint)(instruction.Address + 5 + offset);
// Set the operands // Format the target address
instruction.Operands = $"0x{targetAddress:X8}"; instruction.Operands = $"0x{targetAddress:X8}";
return true; return true;