예제 #1
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"
}
예제 #2
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"
}
예제 #3
0
void
_gum_duk_interceptor_init (GumDukInterceptor * self,
                           GumDukCore * core)
{
  duk_context * ctx = core->ctx;

  self->core = core;

  self->interceptor = gum_interceptor_obtain ();

  self->invocation_listeners = g_hash_table_new_full (NULL, NULL, NULL,
      (GDestroyNotify) gum_duk_invocation_listener_destroy);
  self->replacement_by_address = g_hash_table_new_full (NULL, NULL, NULL,
      (GDestroyNotify) gum_duk_replace_entry_free);

  _gum_duk_store_module_data (ctx, "interceptor", self);

  duk_push_c_function (ctx, gumjs_interceptor_construct, 0);
  duk_push_object (ctx);
  duk_put_function_list (ctx, -1, gumjs_interceptor_functions);
  duk_put_prop_string (ctx, -2, "prototype");
  duk_new (ctx, 0);
  duk_put_global_string (ctx, "Interceptor");

  duk_push_c_function (ctx, gumjs_invocation_listener_construct, 2);
  duk_push_object (ctx);
  duk_put_function_list (ctx, -1, gumjs_invocation_listener_functions);
  duk_put_prop_string (ctx, -2, "prototype");
  self->invocation_listener = _gum_duk_require_heapptr (ctx, -1);
  duk_put_global_string (ctx, "InvocationListener");

  duk_push_c_function (ctx, gumjs_invocation_context_construct, 0);
  duk_push_object (ctx);
  duk_push_c_function (ctx, gumjs_invocation_context_finalize, 1);
  duk_set_finalizer (ctx, -2);
  duk_put_prop_string (ctx, -2, "prototype");
  self->invocation_context = _gum_duk_require_heapptr (ctx, -1);
  duk_put_global_string (ctx, "InvocationContext");
  _gum_duk_add_properties_to_class (ctx, "InvocationContext",
      gumjs_invocation_context_values);

  duk_push_c_function (ctx, gumjs_invocation_args_construct, 0);
  duk_push_object (ctx);
  duk_push_c_function (ctx, gumjs_invocation_args_finalize, 1);
  duk_set_finalizer (ctx, -2);
  duk_put_prop_string (ctx, -2, "prototype");
  self->invocation_args = _gum_duk_require_heapptr (ctx, -1);
  duk_put_global_string (ctx, "InvocationArgs");

  _gum_duk_create_subclass (ctx, "NativePointer", "InvocationReturnValue",
      gumjs_invocation_return_value_construct, 1, NULL);
  duk_get_global_string (ctx, "InvocationReturnValue");
  duk_get_prop_string (ctx, -1, "prototype");
  duk_push_c_function (ctx, gumjs_invocation_return_value_finalize, 1);
  duk_set_finalizer (ctx, -2);
  duk_put_function_list (ctx, -1, gumjs_invocation_return_value_functions);
  duk_pop (ctx);
  self->invocation_retval = _gum_duk_require_heapptr (ctx, -1);
  duk_pop (ctx);

  self->cached_invocation_context = gum_duk_invocation_context_new (self);
  self->cached_invocation_context_in_use = FALSE;

  self->cached_invocation_args = gum_duk_invocation_args_new (self);
  self->cached_invocation_args_in_use = FALSE;

  self->cached_invocation_return_value = gum_duk_invocation_return_value_new (
      self);
  self->cached_invocation_return_value_in_use = FALSE;
}