Sha256: 97ff3c6c54fe2dec4ef5f9c67285764c8cca7cb1dec4ef7858b3fb317d8a76d2

Contents?: true

Size: 1.83 KB

Versions: 1

Compression:

Stored size: 1.83 KB

Contents

#include "Process.h"

VALUE	Process_from_FridaProcess(FridaProcess *handle)
{
    VALUE self;

    if (!handle)
        return (Qnil);
    self = rb_class_new_instance(0, NULL, cProcess);
    GET_GOBJECT_DATA();
    d->handle = handle;
    d->destroy = g_object_unref;
    rb_ivar_set(self, rb_intern("pid"), LL2NUM(frida_process_get_pid(d->handle)));
    rb_ivar_set(self, rb_intern("name"), rb_str_new_cstr(frida_process_get_name(d->handle)));
    rb_ivar_set(self, rb_intern("parameters"), rbProcess_marshal_parameters_dict(frida_process_get_parameters(d->handle)));
    return (self);
}

static VALUE Process_inspect(VALUE self)
{
    VALUE s;

    s = rb_sprintf("#<Process: name=%+"PRIsVALUE", pid=%+"PRIsVALUE", parameters=%+"PRIsVALUE">", \
                   rb_funcall(self, rb_intern("name"), 0, NULL),
                   rb_funcall(self, rb_intern("pid"), 0, NULL),
                   rb_funcall(self, rb_intern("parameters"), 0, NULL)
                  );
    return (s);
}

/*
    call-seq:
        #pid() -> Fixnum
*/
static VALUE Process_pid(VALUE self)
{
    return (rb_ivar_get(self, rb_intern("pid")));
}

/*
    call-seq:
        #name() -> String
*/
static VALUE Process_name(VALUE self)
{
    return (rb_ivar_get(self, rb_intern("name")));
}

/*
    call-seq:
        #parameters() -> Hash
*/
static VALUE Process_parameters(VALUE self)
{
    return (rb_ivar_get(self, rb_intern("parameters")));
}

void	define_Process()
{
    cProcess = rb_define_class_under(mCFrida, "Process", cGObject);

    rb_define_method(cProcess, "inspect", Process_inspect, 0);
    rb_define_alias(cProcess, "to_s", "inspect");
    rb_define_method(cProcess, "pid", Process_pid, 0);
    rb_define_method(cProcess, "name", Process_name, 0);
    rb_define_method(cProcess, "parameters", Process_parameters, 0);
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
frida-0.1.1 ext/c_frida/Process.c