Ok thanks. Glad to understand what's going on now
As for a solution, drwrap seemed like a good idea. However after many attempts I was unable to get it to work. The wraps behaved very strangely and was unreliable for some reason. Normally when I use it to loop a function there are no problems. It seemed as though using the DRWRAP_REPLACE_RETADDR would be a great solution, but it didn't work like I expected.
I decided to go for a more hacky solution to see if it would work.
Since this is impossible:
mov rcx, [rsi+8]
call 1st instrumentation <-- meta
call (some function)
call 2nd instrumentation <-- meta
I thought perhaps this could work:
mov rcx, [rsi+8]
call 1st instrumentation <-- meta
call (some function) <-- meta
call 2nd instrumentation <-- meta
JMP (skip below call)
call (some function)
Oddly enough the program functions correctly but none of the instructions inside (some function) are ever hit in the basic block event. I'm guessing that this has something to do with the fact that the new call is inserted as a meta instruction (with instrlist_meta_preinsert()). Is there a way to make it so that the instructions after the new call are recognized as app instructions? If not are there perhaps any other ways to make this work?
Thanks for the assistance