arm/shared/KernelExploit/Sources/CFastFind/CFastFind.c
/**
 * Emulate an adrp instruction at the given pc value
 * Returns adrp destination
 */
Emulate an adrp instruction at the given pc value
Returns adrp destination
Emulate an adrp instruction at the given pc value Returns adrp destination
uint64_t aarch64_emulate_adrp(uint32_t instruction, uint64_t pc) {
    if ((instruction & 0x9F000000) != 0x90000000) {
        return 0;
    }
    int32_t imm_hi_lo = (instruction & 0xFFFFE0) >> 3;
    imm_hi_lo |= (instruction & 0x60000000) >> 29;
    if (instruction & 0x800000) {
        imm_hi_lo |= 0xFFE00000;
    }
    int64_t imm = ((int64_t) imm_hi_lo << 12);
    return (pc & ~(0xFFFULL)) + imm;
}
uint64_t aarch64_emulate_adrp ( uint32_t instruction , uint64_t pc ) { if ( ( instruction & 0x9F000000 ) != 0x90000000 ) { return 0 ; } int32_t imm_hi_lo = ( instruction & 0xFFFFE0 ) >> 3 ; imm_hi_lo |= ( instruction & 0x60000000 ) >> 29 ; if ( instruction & 0x800000 ) { imm_hi_lo |= 0xFFE00000 ; } int64_t imm = ( ( int64_t ) imm_hi_lo << 12 ) ; return ( pc & ~ ( 0xFFFULL ) ) + imm ; }
Emulate an adrp instruction at the given pc value
 Returns adrp destination
Emulate an adrp instruction at the given pc value Returns adrp destination
// Check that this is an adrp instruction // Calculate imm from hi and lo // Sign extend // Build real imm // Emulate