core/x86/instr.c
/* Returns NULL if pc is not the start of a rip-rel lea.
 * If it could be, returns the address it refers to (which we assume is
 * never NULL).
 */
Returns NULL if pc is not the start of a rip-rel lea.
If it could be, returns the address it refers to (which we assume is
never NULL).
Returns NULL if pc is not the start of a rip - rel lea . If it could be returns the address it refers to ( which we assume is never NULL ) .
byte *
instr_raw_is_rip_rel_lea(byte *pc, byte *read_end)
{
    if (pc + 7 <= read_end) {
        if (*(pc+1) == RAW_OPCODE_lea &&
            (TESTALL(REX_PREFIX_BASE_OPCODE | REX_PREFIX_W_OPFLAG, *pc) &&
             !TESTANY(~(REX_PREFIX_BASE_OPCODE | REX_PREFIX_ALL_OPFLAGS), *pc)) &&
            ((*(pc+2)) | MODRM_BYTE(0,7,0)) == MODRM_BYTE(0,7,5)) {
            return pc + 7 + *(int*)(pc+3);
        }
    }
    return NULL;
}
byte * instr_raw_is_rip_rel_lea ( byte * pc , byte * read_end ) { if ( pc + 7 <= read_end ) { if ( * ( pc + 1 ) == RAW_OPCODE_lea && ( TESTALL ( REX_PREFIX_BASE_OPCODE | REX_PREFIX_W_OPFLAG , * pc ) && ! TESTANY ( ~ ( REX_PREFIX_BASE_OPCODE | REX_PREFIX_ALL_OPFLAGS ) , * pc ) ) && ( ( * ( pc + 2 ) ) | MODRM_BYTE ( 0 , 7 , 0 ) ) == MODRM_BYTE ( 0 , 7 , 5 ) ) { return pc + 7 + * ( int * ) ( pc + 3 ) ; } } return NULL ; }
Returns NULL if pc is not the start of a rip-rel lea.
Returns NULL if pc is not the start of a rip - rel lea .
/* PR 215408: look for "lea reg, [rip+disp]"
     * We assume no extraneous prefixes, and we require rex.w, though not strictly
     * necessary for say WOW64 or other known-lower-4GB situations
     */ /* does mod==0 and rm==5? */