Closed
Description
Feature Request:
Many modern disassemblers expose somewhere in their api a way to determine if a current instruction is relative to EIP/RIP in some manner. The capstone api only exposes the Opcode Types of MEM,IMM,REG, and FP. When writing code relocation utilities such as hooking libraries this is a significant drawback as it is currently impossible to determine if an instruction is relative or not and then modify that displacement if necessary.
This could be resolved by exposing two new features to the api:
- A flag of some sort defining if the currently instruction is RIP/EIP Relative
- An integer value describing the offset in bytes from the beggining of the instruction to the Displacement.
Ex (x64):
jmp [rip+0xDEADBEEF]
"\xFF\x25\xEF\xBE\xAD\xDE"
Proposed API:
cs_insn* CurIns = (cs_insn*)&Instructions[i];
if(CurIns->Flag & X86_INS_REL)
{
Displacement=CurIns->Relative.Displacement; //would be 0xdeadbeef in this example
OffsetToDisp=CurIns->Relative.Offset; //would be 2 in this example
}
Metadata
Metadata
Assignees
Labels
No labels