void gum_allocator_probe_detach (GumAllocatorProbe * self) { GumAllocatorProbePrivate * priv = self->priv; guint i; gum_interceptor_ignore_current_thread (priv->interceptor); gum_interceptor_detach_listener (priv->interceptor, GUM_INVOCATION_LISTENER (self)); for (i = 0; i < priv->function_contexts->len; i++) { FunctionContext * function_ctx = (FunctionContext *) g_ptr_array_index (priv->function_contexts, i); g_free (function_ctx); } g_ptr_array_set_size (priv->function_contexts, 0); priv->malloc_count = 0; priv->realloc_count = 0; priv->free_count = 0; gum_interceptor_unignore_current_thread (priv->interceptor); }
void gum_allocator_probe_attach_to_apis (GumAllocatorProbe * self, const GumHeapApiList * apis) { GumAllocatorProbePrivate * priv = self->priv; guint i; gum_interceptor_ignore_current_thread (priv->interceptor); gum_interceptor_begin_transaction (priv->interceptor); for (i = 0; i != apis->len; i++) { const GumHeapApi * api = gum_heap_api_list_get_nth (apis, i); GUM_ATTACH_TO_API_FUNC (malloc); GUM_ATTACH_TO_API_FUNC (calloc); GUM_ATTACH_TO_API_FUNC (realloc); GUM_ATTACH_TO_API_FUNC (free); if (api->_malloc_dbg != NULL) { GUM_ATTACH_TO_API_FUNC (_malloc_dbg); GUM_ATTACH_TO_API_FUNC (_calloc_dbg); GUM_ATTACH_TO_API_FUNC (_realloc_dbg); GUM_ATTACH_TO_API_FUNC (_free_dbg); } } gum_allocator_probe_apply_default_suppressions (self); gum_interceptor_end_transaction (priv->interceptor); gum_interceptor_unignore_current_thread (priv->interceptor); }
static gboolean gum_flush_pending_unignores (gpointer user_data) { GumJscScriptBackend * self = GUM_JSC_SCRIPT_BACKEND (user_data); GumJscScriptBackendPrivate * priv = self->priv; gum_interceptor_ignore_current_thread (priv->interceptor); g_rw_lock_writer_lock (&priv->ignored_lock); if (priv->pending_timeout == g_main_current_source ()) { g_source_unref (priv->pending_timeout); priv->pending_timeout = NULL; } while (priv->pending_unignores != NULL) { GumThreadId thread_id; thread_id = GPOINTER_TO_SIZE (priv->pending_unignores->data); priv->pending_unignores = g_slist_delete_link (priv->pending_unignores, priv->pending_unignores); gum_jsc_script_backend_adjust_ignore_level_unlocked (self, thread_id, -1); } g_rw_lock_writer_unlock (&priv->ignored_lock); gum_interceptor_unignore_current_thread (priv->interceptor); return FALSE; }
static void gum_jsc_script_backend_unignore_later (GumScriptBackend * backend, GumThreadId thread_id) { GumJscScriptBackend * self = GUM_JSC_SCRIPT_BACKEND (backend); GumJscScriptBackendPrivate * priv = self->priv; GMainContext * main_context; GSource * source; main_context = gum_script_scheduler_get_js_context ( gum_jsc_script_backend_get_scheduler (self)); gum_interceptor_ignore_current_thread (priv->interceptor); g_rw_lock_writer_lock (&priv->ignored_lock); priv->pending_unignores = g_slist_prepend (priv->pending_unignores, GSIZE_TO_POINTER (thread_id)); source = priv->pending_timeout; priv->pending_timeout = NULL; g_rw_lock_writer_unlock (&priv->ignored_lock); if (source != NULL) { g_source_destroy (source); g_source_unref (source); } source = g_timeout_source_new_seconds (5); g_source_set_callback (source, gum_flush_pending_unignores, self, NULL); g_source_attach (source, main_context); g_rw_lock_writer_lock (&priv->ignored_lock); if (priv->pending_timeout == NULL) { priv->pending_timeout = source; source = NULL; } g_rw_lock_writer_unlock (&priv->ignored_lock); if (source != NULL) { g_source_destroy (source); g_source_unref (source); } gum_interceptor_unignore_current_thread (priv->interceptor); }
static void gum_jsc_script_backend_adjust_ignore_level (GumJscScriptBackend * self, GumThreadId thread_id, gint adjustment) { GumJscScriptBackendPrivate * priv = self->priv; gum_interceptor_ignore_current_thread (priv->interceptor); g_rw_lock_writer_lock (&priv->ignored_lock); gum_jsc_script_backend_adjust_ignore_level_unlocked (self, thread_id, adjustment); g_rw_lock_writer_unlock (&priv->ignored_lock); gum_interceptor_unignore_current_thread (priv->interceptor); }
static void gum_on_thread_realize (void) { GumInternalThreadDetails * details; guint i; gum_interceptor_ignore_current_thread (gum_cached_interceptor); details = g_slice_new (GumInternalThreadDetails); details->thread_id = gum_process_get_current_thread_id (); details->n_cloaked_ranges = gum_thread_try_get_ranges (details->cloaked_ranges, GUM_MAX_THREAD_RANGES); gum_cloak_add_thread (details->thread_id); for (i = 0; i != details->n_cloaked_ranges; i++) gum_cloak_add_range (&details->cloaked_ranges[i]); /* This allows us to free the data no matter how the thread exits */ g_private_set (&gum_internal_thread_details_key, details); }
static void gum_allocator_probe_on_enter (GumInvocationListener * listener, GumInvocationContext * context) { GumAllocatorProbe * self = GUM_ALLOCATOR_PROBE_CAST (listener); GumAllocatorProbePrivate * priv = self->priv; FunctionContext * function_ctx; function_ctx = GUM_LINCTX_GET_FUNC_DATA (context, FunctionContext *); gum_interceptor_ignore_current_thread (priv->interceptor); if (function_ctx != NULL) { ThreadContext * base_thread_ctx; base_thread_ctx = GUM_LINCTX_GET_FUNC_INVDATA (context, ThreadContext); base_thread_ctx->ignored = FALSE; function_ctx->handlers.enter_handler (self, base_thread_ctx, context); } }
static void gum_on_thread_dispose (void) { if (gum_cached_interceptor != NULL) gum_interceptor_ignore_current_thread (gum_cached_interceptor); }