Exemplo n.º 1
0
void
_gum_duk_code_writer_dispose (GumDukCodeWriter * self)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (self->core);

#include "gumdukcodewriter-dispose.inc"
}
Exemplo n.º 2
0
void
_gum_duk_code_relocator_dispose (GumDukCodeRelocator * self)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (self->core);

#include "gumdukcoderelocator-dispose.inc"
}
Exemplo n.º 3
0
void
_gum_duk_process_init (GumDukProcess * self,
                       GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->core = core;

  duk_push_c_function (ctx, gumjs_process_construct, 0);
  duk_push_object (ctx);
  duk_put_function_list (ctx, -1, gumjs_process_functions);
  duk_push_string (ctx, GUM_SCRIPT_ARCH);
  duk_put_prop_string (ctx, -2, "arch");
  duk_push_string (ctx, GUM_SCRIPT_PLATFORM);
  duk_put_prop_string (ctx, -2, "platform");
  duk_push_uint (ctx, gum_query_page_size ());
  duk_put_prop_string (ctx, -2, "pageSize");
  duk_push_uint (ctx, GLIB_SIZEOF_VOID_P);
  duk_put_prop_string (ctx, -2, "pointerSize");
  duk_put_prop_string (ctx, -2, "prototype");
  duk_new (ctx, 0);
  _gum_duk_put_data (ctx, -1, self);
  duk_put_global_string (ctx, "Process");
}
Exemplo n.º 4
0
void
_gum_duk_code_writer_init (GumDukCodeWriter * self,
                           GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->core = core;

  _gum_duk_store_module_data (ctx, "code-writer", self);

#include "gumdukcodewriter-init.inc"
}
Exemplo n.º 5
0
static void
gum_duk_exception_handler_free (GumDukExceptionHandler * handler)
{
  GumDukCore * core = handler->core;
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);

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

  _gum_duk_unprotect (scope.ctx, handler->callback);

  g_slice_free (GumDukExceptionHandler, handler);
}
Exemplo n.º 6
0
void
_gum_duk_code_relocator_init (GumDukCodeRelocator * self,
                              GumDukCodeWriter * writer,
                              GumDukInstruction * instruction,
                              GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->writer = writer;
  self->instruction = instruction;
  self->core = core;

  _gum_duk_store_module_data (ctx, "code-relocator", self);

#include "gumdukcoderelocator-init.inc"
}
Exemplo n.º 7
0
void
_gum_duk_kernel_init (GumDukKernel * self,
                      GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  self->core = core;

  duk_push_object (ctx);
  duk_push_uint (ctx, gum_kernel_query_page_size ());
  duk_put_prop_string (ctx, -2, "pageSize");
  _gum_duk_add_properties_to_class_by_heapptr (ctx,
      duk_require_heapptr (ctx, -1), gumjs_kernel_values);
  duk_put_function_list (ctx, -1, gumjs_kernel_functions);
  duk_put_global_string (ctx, "Kernel");
}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
static gboolean
gum_append_match (GumAddress address,
                  gsize size,
                  GumDukCore * core)
{
  GumDukScope scope = GUM_DUK_SCOPE_INIT (core);
  duk_context * ctx = scope.ctx;

  duk_push_object (ctx);

  _gum_duk_push_uint64 (ctx, address, core);
  duk_put_prop_string (ctx, -2, "address");

  duk_push_uint (ctx, size);
  duk_put_prop_string (ctx, -2, "size");

  duk_put_prop_index (ctx, -2, (duk_uarridx_t) duk_get_length (ctx, -2));

  return TRUE;
}
Exemplo n.º 10
0
static gboolean
gum_push_range_if_containing_address (const GumRangeDetails * details,
                                      gpointer user_data)
{
  GumDukFindRangeByAddressContext * fc = user_data;
  gboolean proceed = TRUE;

  if (GUM_MEMORY_RANGE_INCLUDES (details->range, fc->address))
  {
    GumDukScope scope = GUM_DUK_SCOPE_INIT (fc->core);
    duk_context * ctx = scope.ctx;

    duk_pop (ctx);
    _gum_duk_push_range (ctx, details, fc->core);

    proceed = FALSE;
  }

  return proceed;
}