adding inlined instrumentation after a Call instruction

19 views
Skip to first unread message

Mah

unread,
Jun 14, 2023, 10:20:33 AM6/14/23
to DynamoRIO Users
Hi,  I am trying to inline instrumentation before and after every application function call (whether direct or indirect) that basically saves certain registers before the function call  (by pushing it on the stack or saving through dr_insert_write_tls_filed) and restores them after the function call . As far as I know, dr_insert_clean_call is inserted before the instruction.  Similarly, instrlist_meta_postinsert does not work for control transfer instruction such as calls? Also, drwrap_wrap requires a function address, whereas I want to wrap every function call, whether direct or indirect. For me, the most desirable way is to insert meta instructions inlined, as I do not want to touch any other registers than the ones I specifically intend to.  Is there a way to do this? 

Derek Bruening

unread,
Jun 14, 2023, 8:56:56 PM6/14/23
to Mah, DynamoRIO Users
You could record the PC after every call instruction and when you see that PC in another block insert your instrumentation there.  Make sure you handle the case of alternative control flow reaching that PC without going through the call.  Note that not all function invocations are by call instruction (tailcalls use jumps, e.g.).

Also note that you should not push to the application stack unless you intend to modify application behavior.

On Wed, Jun 14, 2023 at 10:20 AM Mah <mahw...@gmail.com> wrote:
Hi,  I am trying to inline instrumentation before and after every application function call (whether direct or indirect) that basically saves certain registers before the function call  (by pushing it on the stack or saving through dr_insert_write_tls_filed) and restores them after the function call . As far as I know, dr_insert_clean_call is inserted before the instruction.  Similarly, instrlist_meta_postinsert does not work for control transfer instruction such as calls? Also, drwrap_wrap requires a function address, whereas I want to wrap every function call, whether direct or indirect. For me, the most desirable way is to insert meta instructions inlined, as I do not want to touch any other registers than the ones I specifically intend to.  Is there a way to do this? 

--
You received this message because you are subscribed to the Google Groups "DynamoRIO Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dynamorio-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dynamorio-users/85603490-cb3c-4da4-958b-e7eb9f025cd7n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages