diff --git a/gum/guminterceptor.c b/gum/guminterceptor.c index 4d8d14a70..b2b3d5489 100644 --- a/gum/guminterceptor.c +++ b/gum/guminterceptor.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2022 Ole André Vadla Ravnås + * Copyright (C) 2008-2024 Ole André Vadla Ravnås * Copyright (C) 2008 Christian Berentsen * Copyright (C) 2024 Francesco Tamagni * @@ -705,6 +705,24 @@ gum_interceptor_get_current_invocation (void) return &entry->invocation_context; } +GumInvocationContext * +gum_interceptor_get_live_replacement_invocation (gpointer replacement_function) +{ + InterceptorThreadContext * interceptor_ctx; + GumInvocationStackEntry * entry; + + interceptor_ctx = get_interceptor_thread_context (); + entry = gum_invocation_stack_peek_top (interceptor_ctx->stack); + if (entry == NULL) + return NULL; + if (!entry->calling_replacement) + return NULL; + if (replacement_function != entry->function_ctx->replacement_function) + return NULL; + + return &entry->invocation_context; +} + GumInvocationStack * gum_interceptor_get_current_stack (void) { diff --git a/gum/guminterceptor.h b/gum/guminterceptor.h index ae002d09e..40bc6c8f3 100644 --- a/gum/guminterceptor.h +++ b/gum/guminterceptor.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008-2022 Ole André Vadla Ravnås + * Copyright (C) 2008-2024 Ole André Vadla Ravnås * Copyright (C) 2008 Christian Berentsen * Copyright (C) 2024 Francesco Tamagni * @@ -62,6 +62,8 @@ GUM_API void gum_interceptor_end_transaction (GumInterceptor * self); GUM_API gboolean gum_interceptor_flush (GumInterceptor * self); GUM_API GumInvocationContext * gum_interceptor_get_current_invocation (void); +GUM_API GumInvocationContext * gum_interceptor_get_live_replacement_invocation ( + gpointer replacement_function); GUM_API GumInvocationStack * gum_interceptor_get_current_stack (void); GUM_API void gum_interceptor_ignore_current_thread (GumInterceptor * self);