NokiaTube | New address | Mode Phone | On high quality
Skip to content

Interceptor on arm64 breaks functions with internal backward jumps to the middle of the trampoline (offset +4) #1083

Open

Description

@nocchijiang

I encountered a crash when hooking CoreFoundation's CFStringGetCharacterAtIndex on iOS/arm64 using the latest release. It overwrites the first 8 bytes of the function to place the trampoline. However, this specific function contains internal backward branches that target offset +4.

Original Disassembly

CoreFoundation`CFStringGetCharacterAtIndex:
    0x194d61494 <+0>:   tbz    x0, #0x3f, 0x194d614a0     ; <+12>
    0x194d61498 <+4>:   mov    x2, x1
    0x194d6149c <+8>:   b      0x19508f340                ; objc_msgSend$characterAtIndex:
    ...
    0x194d614cc <+56>:  tbz    w8, #0x0, 0x194d61498      ; Jumps back to +4

Hooked Disassembly

CoreFoundation`CFStringGetCharacterAtIndex:
    0x194d61494 <+0>:   adrp   x16, -595979
    0x194d61498 <+4>:   br     x16
    0x194d6149c <+8>:   b      0x19508f340                ; objc_msgSend$characterAtIndex:
    ...
    0x194d614cc <+56>:  tbz    w8, #0x0, 0x194d61498      ; Jumps to +4 (now 'br x16')

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions