mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 20:01:17 +03:00
Simplified JmpRel32Handler by improving target address calculation and code organization
This commit is contained in:
parent
38770de005
commit
996be18172
@ -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;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user