Пример #1
0
static GumJscExceptionHandler *
gum_jsc_exception_handler_new (JSObjectRef callback,
                               GumJscCore * core)
{
  GumJscExceptionHandler * handler;

  handler = g_slice_new (GumJscExceptionHandler);
  JSValueProtect (core->ctx, callback);
  handler->callback = callback;
  handler->core = core;

  gum_exceptor_add (core->exceptor, gum_jsc_exception_handler_on_exception,
      handler);

  return handler;
}
gboolean
gum_memory_access_monitor_enable (GumMemoryAccessMonitor * self,
                                  GError ** error)
{
  GumMemoryAccessMonitorPrivate * priv = self->priv;
  GumRangeStats stats;

  if (priv->enabled)
    return TRUE;

  stats.live_size = 0;
  stats.guarded_size = 0;
  gum_memory_access_monitor_enumerate_live_ranges (self,
      gum_collect_range_stats, &stats);

  if (stats.live_size != priv->pages_total * priv->page_size)
    goto error_invalid_pages;
  else if (stats.guarded_size != 0)
    goto error_guarded_pages;

  priv->exceptor = gum_exceptor_obtain ();
  gum_exceptor_add (priv->exceptor, gum_memory_access_monitor_on_exception,
      self);

  priv->num_pages = 0;
  priv->pages_details = NULL;
  gum_memory_access_monitor_enumerate_live_ranges (self,
      gum_set_guard_flag, self);

  priv->enabled = TRUE;

  return TRUE;

error_invalid_pages:
  {
    g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
        "one or more pages are unallocated");
    return FALSE;
  }
error_guarded_pages:
  {
    g_set_error (error, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
        "one or more pages already have the guard bit set");
    return FALSE;
  }
}
Пример #3
0
static GumDukExceptionHandler *
gum_duk_exception_handler_new (GumDukHeapPtr callback,
                               GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  GumDukExceptionHandler * handler;

  handler = g_slice_new (GumDukExceptionHandler);
  _gum_duk_protect (scope.ctx, callback);
  handler->callback = callback;
  handler->core = core;

  gum_exceptor_add (core->exceptor, gum_duk_exception_handler_on_exception,
      handler);

  return handler;
}