mirror of
https://github.com/sampletext32/ParkanPlayground.git
synced 2025-05-19 03:41:18 +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
|
||||
instruction.Mnemonic = "jmp";
|
||||
|
||||
// Check if we have enough bytes for the offset
|
||||
int position = Decoder.GetPosition();
|
||||
|
||||
if (position + 4 > Length)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Read the relative offset
|
||||
uint offset = Decoder.ReadUInt32();
|
||||
// Read the offset and calculate target address
|
||||
int offset = (int)Decoder.ReadUInt32();
|
||||
|
||||
// Calculate the target address
|
||||
uint targetAddress = (uint)(position + offset + 4);
|
||||
// Calculate target address (instruction address + instruction length + offset)
|
||||
// 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}";
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user