Beispiel #1
0
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);
}
GumAttachReturn
interceptor_fixture_try_attaching_listener (TestInterceptorFixture * h,
                                            guint listener_index,
                                            gpointer test_func,
                                            gchar enter_char,
                                            gchar leave_char)
{
  GumAttachReturn result;
  DarwinListenerContext * ctx;

  if (h->listener_context[listener_index] != NULL)
  {
    g_object_unref (h->listener_context[listener_index]);
    h->listener_context[listener_index] = NULL;
  }

  ctx = (DarwinListenerContext *) g_object_new (
      listener_context_get_type (), NULL);
  ctx->harness = h;
  ctx->enter_char = enter_char;
  ctx->leave_char = leave_char;

  result = gum_interceptor_attach_listener (h->interceptor, test_func,
      GUM_INVOCATION_LISTENER (ctx), NULL);
  if (result == GUM_ATTACH_OK)
  {
    h->listener_context[listener_index] = ctx;
  }
  else
  {
    g_object_unref (ctx);
  }

  return result;
}
Beispiel #3
0
static void
gum_duk_invocation_listener_destroy (GumDukInvocationListener * listener)
{
  gum_interceptor_detach_listener (listener->module->interceptor,
      GUM_INVOCATION_LISTENER (listener));
  g_object_unref (listener);
}
Beispiel #4
0
void
gum_allocator_probe_suppress (GumAllocatorProbe * self,
                              gpointer function_address)
{
  GumAllocatorProbePrivate * priv = self->priv;
  GumInvocationListener * listener = GUM_INVOCATION_LISTENER (self);
  GumAttachReturn attach_ret;

  attach_ret = gum_interceptor_attach_listener (priv->interceptor,
      function_address, listener, NULL);
  g_assert (attach_ret == GUM_ATTACH_OK);
}
Beispiel #5
0
static void
attach_to_function (GumAllocatorProbe * self,
                    gpointer function_address,
                    const HeapHandlers * function_handlers)
{
  GumAllocatorProbePrivate * priv = self->priv;
  GumInvocationListener * listener = GUM_INVOCATION_LISTENER (self);
  FunctionContext * function_ctx;
  GumAttachReturn attach_ret;

  function_ctx = g_new0 (FunctionContext, 1);
  function_ctx->handlers = *function_handlers;
  g_ptr_array_add (priv->function_contexts, function_ctx);

  attach_ret = gum_interceptor_attach_listener (priv->interceptor,
      function_address, listener, function_ctx);
  g_assert (attach_ret == GUM_ATTACH_OK);
}
static void
test_interceptor_fixture_teardown (TestInterceptorFixture * fixture,
                                   gconstpointer data)
{
  guint i;

  (void) data;

  for (i = 0; i < G_N_ELEMENTS (fixture->listener_context); i++)
  {
    DarwinListenerContext * ctx = fixture->listener_context[i];

    if (ctx != NULL)
    {
      gum_interceptor_detach_listener (fixture->interceptor,
          GUM_INVOCATION_LISTENER (ctx));
      g_object_unref (ctx);
    }
  }

  g_string_free (fixture->result, TRUE);
  g_object_unref (fixture->interceptor);
}