frida 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +25 -0
- data/LICENSE.txt +21 -0
- data/README.md +64 -0
- data/Rakefile +20 -0
- data/exe/frida +3 -0
- data/ext/c_frida/Application.c +79 -0
- data/ext/c_frida/Bus.c +91 -0
- data/ext/c_frida/Child.c +134 -0
- data/ext/c_frida/Compiler.c +208 -0
- data/ext/c_frida/Crash.c +92 -0
- data/ext/c_frida/Device.c +955 -0
- data/ext/c_frida/DeviceManager.c +260 -0
- data/ext/c_frida/EndpointParameters.c +189 -0
- data/ext/c_frida/FileMonitor.c +67 -0
- data/ext/c_frida/GObject.c +138 -0
- data/ext/c_frida/IOStream.c +228 -0
- data/ext/c_frida/PortalMembership.c +43 -0
- data/ext/c_frida/PortalService.c +413 -0
- data/ext/c_frida/Process.c +67 -0
- data/ext/c_frida/Relay.c +121 -0
- data/ext/c_frida/Script.c +221 -0
- data/ext/c_frida/Session.c +626 -0
- data/ext/c_frida/Spawn.c +53 -0
- data/ext/c_frida/c_frida.c +68 -0
- data/ext/c_frida/extconf.rb +26 -25
- data/ext/c_frida/gutils.c +498 -0
- data/ext/c_frida/gvl_bridge.c +131 -0
- data/ext/c_frida/inc/Application.h +9 -0
- data/ext/c_frida/inc/Bus.h +15 -0
- data/ext/c_frida/inc/Child.h +9 -0
- data/ext/c_frida/inc/Compiler.h +21 -0
- data/ext/c_frida/inc/Crash.h +9 -0
- data/ext/c_frida/inc/Device.h +71 -0
- data/ext/c_frida/inc/DeviceManager.h +20 -0
- data/ext/c_frida/inc/EndpointParameters.h +15 -0
- data/ext/c_frida/inc/FileMonitor.h +9 -0
- data/ext/c_frida/inc/GObject.h +10 -0
- data/ext/c_frida/inc/IOStream.h +29 -0
- data/ext/c_frida/inc/PortalMembership.h +9 -0
- data/ext/c_frida/inc/PortalService.h +47 -0
- data/ext/c_frida/inc/Process.h +9 -0
- data/ext/c_frida/inc/Relay.h +9 -0
- data/ext/c_frida/inc/Script.h +21 -0
- data/ext/c_frida/inc/Session.h +40 -0
- data/ext/c_frida/inc/Spawn.h +9 -0
- data/ext/c_frida/inc/c_frida.h +129 -0
- data/ext/c_frida/inc/gutils.h +21 -0
- data/ext/c_frida/inc/gvl_bridge.h +42 -0
- data/frida.gemspec +39 -0
- data/lib/frida/version.rb +5 -0
- data/lib/frida.rb +8 -0
- metadata +55 -3
| @@ -0,0 +1,67 @@ | |
| 1 | 
            +
            #include "Process.h"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            VALUE	Process_from_FridaProcess(FridaProcess *handle)
         | 
| 4 | 
            +
            {
         | 
| 5 | 
            +
                VALUE self;
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                if (!handle)
         | 
| 8 | 
            +
                    return (Qnil);
         | 
| 9 | 
            +
                self = rb_class_new_instance(0, NULL, cProcess);
         | 
| 10 | 
            +
                GET_GOBJECT_DATA();
         | 
| 11 | 
            +
                d->handle = handle;
         | 
| 12 | 
            +
                d->destroy = g_object_unref;
         | 
| 13 | 
            +
                rb_ivar_set(self, rb_intern("pid"), LL2NUM(frida_process_get_pid(d->handle)));
         | 
| 14 | 
            +
                rb_ivar_set(self, rb_intern("name"), rb_str_new_cstr(frida_process_get_name(d->handle)));
         | 
| 15 | 
            +
                rb_ivar_set(self, rb_intern("parameters"), rbProcess_marshal_parameters_dict(frida_process_get_parameters(d->handle)));
         | 
| 16 | 
            +
                return (self);
         | 
| 17 | 
            +
            }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            static VALUE Process_inspect(VALUE self)
         | 
| 20 | 
            +
            {
         | 
| 21 | 
            +
                VALUE s;
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                s = rb_sprintf("#<Process: name=%+"PRIsVALUE", pid=%+"PRIsVALUE", parameters=%+"PRIsVALUE">", \
         | 
| 24 | 
            +
                               rb_funcall(self, rb_intern("name"), 0, NULL),
         | 
| 25 | 
            +
                               rb_funcall(self, rb_intern("pid"), 0, NULL),
         | 
| 26 | 
            +
                               rb_funcall(self, rb_intern("parameters"), 0, NULL)
         | 
| 27 | 
            +
                              );
         | 
| 28 | 
            +
                return (s);
         | 
| 29 | 
            +
            }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            /*
         | 
| 32 | 
            +
                call-seq:
         | 
| 33 | 
            +
                    #pid() -> Fixnum
         | 
| 34 | 
            +
            */
         | 
| 35 | 
            +
            static VALUE Process_pid(VALUE self)
         | 
| 36 | 
            +
            {
         | 
| 37 | 
            +
                return (rb_ivar_get(self, rb_intern("pid")));
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            /*
         | 
| 41 | 
            +
                call-seq:
         | 
| 42 | 
            +
                    #name() -> String
         | 
| 43 | 
            +
            */
         | 
| 44 | 
            +
            static VALUE Process_name(VALUE self)
         | 
| 45 | 
            +
            {
         | 
| 46 | 
            +
                return (rb_ivar_get(self, rb_intern("name")));
         | 
| 47 | 
            +
            }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            /*
         | 
| 50 | 
            +
                call-seq:
         | 
| 51 | 
            +
                    #parameters() -> Hash
         | 
| 52 | 
            +
            */
         | 
| 53 | 
            +
            static VALUE Process_parameters(VALUE self)
         | 
| 54 | 
            +
            {
         | 
| 55 | 
            +
                return (rb_ivar_get(self, rb_intern("parameters")));
         | 
| 56 | 
            +
            }
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            void	define_Process()
         | 
| 59 | 
            +
            {
         | 
| 60 | 
            +
                cProcess = rb_define_class_under(mCFrida, "Process", cGObject);
         | 
| 61 | 
            +
             | 
| 62 | 
            +
                rb_define_method(cProcess, "inspect", Process_inspect, 0);
         | 
| 63 | 
            +
                rb_define_alias(cProcess, "to_s", "inspect");
         | 
| 64 | 
            +
                rb_define_method(cProcess, "pid", Process_pid, 0);
         | 
| 65 | 
            +
                rb_define_method(cProcess, "name", Process_name, 0);
         | 
| 66 | 
            +
                rb_define_method(cProcess, "parameters", Process_parameters, 0);
         | 
| 67 | 
            +
            }
         | 
    
        data/ext/c_frida/Relay.c
    ADDED
    
    | @@ -0,0 +1,121 @@ | |
| 1 | 
            +
            #include "Relay.h"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            VALUE Relay_from_FridaRelay(FridaRelay *handle)
         | 
| 4 | 
            +
            {
         | 
| 5 | 
            +
                VALUE self;
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                if (!handle)
         | 
| 8 | 
            +
                    return (Qnil);
         | 
| 9 | 
            +
                VALUE args[4] = {Qfalse};
         | 
| 10 | 
            +
                self = rb_class_new_instance(4, args, cRelay);
         | 
| 11 | 
            +
                GET_GOBJECT_DATA();
         | 
| 12 | 
            +
                d->handle = handle;
         | 
| 13 | 
            +
                d->destroy = g_object_unref;
         | 
| 14 | 
            +
                rb_ivar_set(self, rb_intern("address"), rbGObject_marshal_string(frida_relay_get_address(handle)));
         | 
| 15 | 
            +
                rb_ivar_set(self, rb_intern("username"), rbGObject_marshal_string(frida_relay_get_username(handle)));
         | 
| 16 | 
            +
                rb_ivar_set(self, rb_intern("password"), rbGObject_marshal_string(frida_relay_get_password(handle)));
         | 
| 17 | 
            +
                rb_ivar_set(self, rb_intern("kind"), rbGObject_marshal_enum(frida_relay_get_kind(handle), FRIDA_TYPE_RELAY_KIND));
         | 
| 18 | 
            +
                return (self);
         | 
| 19 | 
            +
            }
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            static VALUE Relay_inspect(VALUE self)
         | 
| 22 | 
            +
            {
         | 
| 23 | 
            +
                VALUE s;
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                s = rb_sprintf("#<Relay: address=%+"PRIsVALUE", username=%+"PRIsVALUE", password=%+"PRIsVALUE", kind=%+"PRIsVALUE">", \
         | 
| 26 | 
            +
                               rb_funcall(self, rb_intern("address"), 0, NULL),  rb_funcall(self, rb_intern("username"), 0, NULL), \
         | 
| 27 | 
            +
                               rb_funcall(self, rb_intern("password"), 0, NULL),  rb_funcall(self, rb_intern("kind"), 0, NULL));
         | 
| 28 | 
            +
                return (s);
         | 
| 29 | 
            +
            }
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            /*
         | 
| 32 | 
            +
                call-seq:
         | 
| 33 | 
            +
                    #address() -> String
         | 
| 34 | 
            +
            */
         | 
| 35 | 
            +
            static VALUE Relay_address(VALUE self)
         | 
| 36 | 
            +
            {
         | 
| 37 | 
            +
                return (rb_ivar_get(self, rb_intern("address")));
         | 
| 38 | 
            +
            }
         | 
| 39 | 
            +
             | 
| 40 | 
            +
            /*
         | 
| 41 | 
            +
                call-seq:
         | 
| 42 | 
            +
                    #username() -> String
         | 
| 43 | 
            +
            */
         | 
| 44 | 
            +
            static VALUE Relay_username(VALUE self)
         | 
| 45 | 
            +
            {
         | 
| 46 | 
            +
                return (rb_ivar_get(self, rb_intern("username")));
         | 
| 47 | 
            +
            }
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            /*
         | 
| 50 | 
            +
                call-seq:
         | 
| 51 | 
            +
                    #password() -> String
         | 
| 52 | 
            +
            */
         | 
| 53 | 
            +
            static VALUE Relay_password(VALUE self)
         | 
| 54 | 
            +
            {
         | 
| 55 | 
            +
                return (rb_ivar_get(self, rb_intern("password")));
         | 
| 56 | 
            +
            }
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            /*
         | 
| 59 | 
            +
                call-seq:
         | 
| 60 | 
            +
                    #kind() -> String
         | 
| 61 | 
            +
            */
         | 
| 62 | 
            +
            static VALUE Relay_kind(VALUE self)
         | 
| 63 | 
            +
            {
         | 
| 64 | 
            +
                return (rb_ivar_get(self, rb_intern("kind")));
         | 
| 65 | 
            +
            }
         | 
| 66 | 
            +
             | 
| 67 | 
            +
            /*
         | 
| 68 | 
            +
                call-seq:
         | 
| 69 | 
            +
                    #new(address, username, password, kind) -> Relay
         | 
| 70 | 
            +
            */
         | 
| 71 | 
            +
            static VALUE Relay_initialize(VALUE self, VALUE address, VALUE username, VALUE password, VALUE kind)
         | 
| 72 | 
            +
            {
         | 
| 73 | 
            +
                GET_GOBJECT_DATA();
         | 
| 74 | 
            +
                FridaRelayKind	gkind;
         | 
| 75 | 
            +
                FridaRelay		*handle;
         | 
| 76 | 
            +
             | 
| 77 | 
            +
                if (address == Qfalse)
         | 
| 78 | 
            +
                    return (self);
         | 
| 79 | 
            +
                if (!RB_TYPE_P(address, T_STRING)) {
         | 
| 80 | 
            +
                    raise_argerror("address should be a string.");
         | 
| 81 | 
            +
                    return (Qnil);
         | 
| 82 | 
            +
                }
         | 
| 83 | 
            +
                if (!RB_TYPE_P(username, T_STRING)) {
         | 
| 84 | 
            +
                    raise_argerror("username should be a string.");
         | 
| 85 | 
            +
                    return (Qnil);
         | 
| 86 | 
            +
                }
         | 
| 87 | 
            +
                if (!RB_TYPE_P(password, T_STRING)) {
         | 
| 88 | 
            +
                    raise_argerror("password should be a string.");
         | 
| 89 | 
            +
                    return (Qnil);
         | 
| 90 | 
            +
                }
         | 
| 91 | 
            +
                if (!RB_TYPE_P(kind, T_STRING)) {
         | 
| 92 | 
            +
                    raise_argerror("kind should be a string.");
         | 
| 93 | 
            +
                    return (Qnil);
         | 
| 94 | 
            +
                }
         | 
| 95 | 
            +
                if (!rbGObject_unmarshal_enum(StringValueCStr(kind), FRIDA_TYPE_RELAY_KIND, &gkind)) {
         | 
| 96 | 
            +
                    raise_argerror("kind is not valid.");
         | 
| 97 | 
            +
                    return (Qnil);
         | 
| 98 | 
            +
                }
         | 
| 99 | 
            +
                handle = frida_relay_new(StringValueCStr(address), StringValueCStr(username), StringValueCStr(password), gkind);
         | 
| 100 | 
            +
                d->handle = handle;
         | 
| 101 | 
            +
                d->destroy = g_object_unref;
         | 
| 102 | 
            +
                rb_ivar_set(self, rb_intern("address"), rbGObject_marshal_string(frida_relay_get_address(handle)));
         | 
| 103 | 
            +
                rb_ivar_set(self, rb_intern("username"), rbGObject_marshal_string(frida_relay_get_username(handle)));
         | 
| 104 | 
            +
                rb_ivar_set(self, rb_intern("password"), rbGObject_marshal_string(frida_relay_get_password(handle)));
         | 
| 105 | 
            +
                rb_ivar_set(self, rb_intern("kind"), rbGObject_marshal_enum(frida_relay_get_kind(handle), FRIDA_TYPE_RELAY_KIND));
         | 
| 106 | 
            +
                return (self);
         | 
| 107 | 
            +
            }
         | 
| 108 | 
            +
             | 
| 109 | 
            +
            void	define_Relay()
         | 
| 110 | 
            +
            {
         | 
| 111 | 
            +
                cRelay = rb_define_class_under(mCFrida, "Relay", cGObject);
         | 
| 112 | 
            +
             | 
| 113 | 
            +
                rb_define_method(cRelay, "inspect", Relay_inspect, 0);
         | 
| 114 | 
            +
                rb_define_alias(cRelay, "to_s", "inspect");
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                rb_define_method(cRelay, "initialize", Relay_initialize, 4);
         | 
| 117 | 
            +
                rb_define_method(cRelay, "address", Relay_address, 0);
         | 
| 118 | 
            +
                rb_define_method(cRelay, "username", Relay_username, 0);
         | 
| 119 | 
            +
                rb_define_method(cRelay, "password", Relay_password, 0);
         | 
| 120 | 
            +
                rb_define_method(cRelay, "kind", Relay_kind, 0);
         | 
| 121 | 
            +
            }
         | 
| @@ -0,0 +1,221 @@ | |
| 1 | 
            +
            #include "Script.h"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            VALUE	Script_from_FridaScript(FridaScript *handle)
         | 
| 4 | 
            +
            {
         | 
| 5 | 
            +
                VALUE self;
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                if (!handle)
         | 
| 8 | 
            +
                    return (Qnil);
         | 
| 9 | 
            +
                self = rb_class_new_instance(0, NULL, cScript);
         | 
| 10 | 
            +
                GET_GOBJECT_DATA();
         | 
| 11 | 
            +
                d->handle = handle;
         | 
| 12 | 
            +
                d->destroy = frida_unref;
         | 
| 13 | 
            +
                return (self);
         | 
| 14 | 
            +
            }
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            /*
         | 
| 17 | 
            +
                call-seq:
         | 
| 18 | 
            +
                    #is_destroyed() -> [TrueClass, FalseClass]
         | 
| 19 | 
            +
            */
         | 
| 20 | 
            +
            static VALUE Script_is_destroyed(VALUE self)
         | 
| 21 | 
            +
            {
         | 
| 22 | 
            +
                GET_GOBJECT_DATA();
         | 
| 23 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 24 | 
            +
                void	*is_destroyed;
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                is_destroyed = rb_thread_call_without_gvl((void_fp)frida_script_is_destroyed, d->handle, NULL, NULL);
         | 
| 27 | 
            +
                return (is_destroyed ? Qtrue : Qfalse);
         | 
| 28 | 
            +
            }
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            GVL_FREE_PROXY_FUNC(load_sync, void *handle)
         | 
| 31 | 
            +
            {
         | 
| 32 | 
            +
                GError *gerr = NULL;
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                frida_script_load_sync(handle, NULL, &gerr);
         | 
| 35 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 36 | 
            +
            }
         | 
| 37 | 
            +
             | 
| 38 | 
            +
            /*
         | 
| 39 | 
            +
                call-seq:
         | 
| 40 | 
            +
                    #load() -> nil
         | 
| 41 | 
            +
            */
         | 
| 42 | 
            +
            static VALUE Script_load(VALUE self)
         | 
| 43 | 
            +
            {
         | 
| 44 | 
            +
                GET_GOBJECT_DATA();
         | 
| 45 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 46 | 
            +
             | 
| 47 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, load_sync, d->handle);
         | 
| 48 | 
            +
                return (Qnil);
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                GERROR_BLOCK
         | 
| 51 | 
            +
            }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            GVL_FREE_PROXY_FUNC(eternalize_sync, void *handle)
         | 
| 54 | 
            +
            {
         | 
| 55 | 
            +
                GError *gerr = NULL;
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                frida_script_eternalize_sync(handle, NULL, &gerr);
         | 
| 58 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 59 | 
            +
            }
         | 
| 60 | 
            +
             | 
| 61 | 
            +
            /*
         | 
| 62 | 
            +
                call-seq:
         | 
| 63 | 
            +
                    #eternalize() -> nil
         | 
| 64 | 
            +
            */
         | 
| 65 | 
            +
            static VALUE Script_eternalize(VALUE self)
         | 
| 66 | 
            +
            {
         | 
| 67 | 
            +
                GET_GOBJECT_DATA();
         | 
| 68 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, eternalize_sync, d->handle);
         | 
| 71 | 
            +
                return (Qnil);
         | 
| 72 | 
            +
             | 
| 73 | 
            +
                GERROR_BLOCK
         | 
| 74 | 
            +
            }
         | 
| 75 | 
            +
             | 
| 76 | 
            +
            GVL_FREE_PROXY_FUNC(unload_sync, void *handle)
         | 
| 77 | 
            +
            {
         | 
| 78 | 
            +
                GError *gerr = NULL;
         | 
| 79 | 
            +
             | 
| 80 | 
            +
                frida_script_unload_sync(handle, NULL, &gerr);
         | 
| 81 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 82 | 
            +
            }
         | 
| 83 | 
            +
             | 
| 84 | 
            +
            /*
         | 
| 85 | 
            +
                call-seq:
         | 
| 86 | 
            +
                    #unload() -> nil
         | 
| 87 | 
            +
            */
         | 
| 88 | 
            +
            static VALUE Script_unload(VALUE self)
         | 
| 89 | 
            +
            {
         | 
| 90 | 
            +
                GET_GOBJECT_DATA();
         | 
| 91 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 92 | 
            +
             | 
| 93 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, unload_sync, d->handle);
         | 
| 94 | 
            +
                return (Qnil);
         | 
| 95 | 
            +
             | 
| 96 | 
            +
                GERROR_BLOCK
         | 
| 97 | 
            +
            }
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            GVL_FREE_PROXY_FUNC(disable_debugger_sync, void *handle)
         | 
| 100 | 
            +
            {
         | 
| 101 | 
            +
                GError *gerr = NULL;
         | 
| 102 | 
            +
             | 
| 103 | 
            +
                frida_script_disable_debugger_sync(handle, NULL, &gerr);
         | 
| 104 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 105 | 
            +
            }
         | 
| 106 | 
            +
             | 
| 107 | 
            +
            /*
         | 
| 108 | 
            +
                call-seq:
         | 
| 109 | 
            +
                    #disable_debugger() -> nil
         | 
| 110 | 
            +
            */
         | 
| 111 | 
            +
            static VALUE Script_disable_debugger(VALUE self)
         | 
| 112 | 
            +
            {
         | 
| 113 | 
            +
                GET_GOBJECT_DATA();
         | 
| 114 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 115 | 
            +
             | 
| 116 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, disable_debugger_sync, d->handle);
         | 
| 117 | 
            +
                return (Qnil);
         | 
| 118 | 
            +
             | 
| 119 | 
            +
                GERROR_BLOCK
         | 
| 120 | 
            +
            }
         | 
| 121 | 
            +
             | 
| 122 | 
            +
            GVL_FREE_PROXY_FUNC(enable_debugger_sync, enable_debugger_proxy_args *args)
         | 
| 123 | 
            +
            {
         | 
| 124 | 
            +
                GError *gerr = NULL;
         | 
| 125 | 
            +
             | 
| 126 | 
            +
                frida_script_enable_debugger_sync(args->handle, args->port, NULL, &gerr);
         | 
| 127 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 128 | 
            +
            }
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            /*
         | 
| 131 | 
            +
                call-seq:
         | 
| 132 | 
            +
                    #enable_debugger(port:) -> nil
         | 
| 133 | 
            +
            */
         | 
| 134 | 
            +
            static VALUE Script_enable_debugger(int argc, VALUE *argv, VALUE self)
         | 
| 135 | 
            +
            {
         | 
| 136 | 
            +
                GET_GOBJECT_DATA();
         | 
| 137 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 138 | 
            +
                VALUE kws, rport;
         | 
| 139 | 
            +
                uint port = 0;
         | 
| 140 | 
            +
             | 
| 141 | 
            +
                rb_scan_args(argc, argv, ":", &kws);
         | 
| 142 | 
            +
                if (!NIL_P(kws)) {
         | 
| 143 | 
            +
                    rport = rb_hash_aref(kws, ID2SYM(rb_intern("port")));
         | 
| 144 | 
            +
                    if (!NIL_P(rport)) {
         | 
| 145 | 
            +
                        if (!RB_TYPE_P(rport, T_FIXNUM)) {
         | 
| 146 | 
            +
                            raise_argerror("port must be a number.");
         | 
| 147 | 
            +
                            return (Qnil);
         | 
| 148 | 
            +
                        }
         | 
| 149 | 
            +
                        port = NUM2UINT(rport);
         | 
| 150 | 
            +
                    }
         | 
| 151 | 
            +
                }
         | 
| 152 | 
            +
                enable_debugger_proxy_args args = {
         | 
| 153 | 
            +
                    .handle = d->handle,
         | 
| 154 | 
            +
                    .port = port
         | 
| 155 | 
            +
                };
         | 
| 156 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, enable_debugger_sync, &args);
         | 
| 157 | 
            +
                goto done;
         | 
| 158 | 
            +
             | 
| 159 | 
            +
            gerror:
         | 
| 160 | 
            +
                raise_rerror(NULL, _gerr);
         | 
| 161 | 
            +
            done:
         | 
| 162 | 
            +
                return (Qnil);
         | 
| 163 | 
            +
            }
         | 
| 164 | 
            +
             | 
| 165 | 
            +
            GVL_FREE_PROXY_FUNC(post, post_proxy_args *args)
         | 
| 166 | 
            +
            {
         | 
| 167 | 
            +
                GError *gerr = NULL;
         | 
| 168 | 
            +
             | 
| 169 | 
            +
                frida_script_post(args->handle, args->message, args->data);
         | 
| 170 | 
            +
                RETURN_GVL_FREE_RESULT(NULL);
         | 
| 171 | 
            +
            }
         | 
| 172 | 
            +
             | 
| 173 | 
            +
            /*
         | 
| 174 | 
            +
                call-seq:
         | 
| 175 | 
            +
                    #post(message, data:) -> nil
         | 
| 176 | 
            +
            */
         | 
| 177 | 
            +
            static VALUE Script_post(int argc, VALUE *argv, VALUE self)
         | 
| 178 | 
            +
            {
         | 
| 179 | 
            +
                GET_GOBJECT_DATA();
         | 
| 180 | 
            +
                REQUIRE_GOBJECT_HANDLE();
         | 
| 181 | 
            +
                VALUE kws, msg, data;
         | 
| 182 | 
            +
                gpointer cdata = NULL;
         | 
| 183 | 
            +
             | 
| 184 | 
            +
                rb_scan_args(argc, argv, "1:", &msg, &kws);
         | 
| 185 | 
            +
                if (!NIL_P(kws)) {
         | 
| 186 | 
            +
                    data = rb_hash_aref(kws, ID2SYM(rb_intern("data")));
         | 
| 187 | 
            +
                    if (!NIL_P(data)) {
         | 
| 188 | 
            +
                        if (!RB_TYPE_P(data, T_STRING)) {
         | 
| 189 | 
            +
                            raise_argerror("data must be a number.");
         | 
| 190 | 
            +
                            return (Qnil);
         | 
| 191 | 
            +
                        }
         | 
| 192 | 
            +
                        cdata = g_bytes_new(RSTRING_PTR(data), RSTRING_LEN(data));
         | 
| 193 | 
            +
                    }
         | 
| 194 | 
            +
                }
         | 
| 195 | 
            +
                post_proxy_args args = {
         | 
| 196 | 
            +
                    .handle = d->handle,
         | 
| 197 | 
            +
                    .message = StringValueCStr(msg),
         | 
| 198 | 
            +
                    .data = cdata
         | 
| 199 | 
            +
                };
         | 
| 200 | 
            +
                CALL_GVL_FREE_WITH_RET(void *dummy, post, &args);
         | 
| 201 | 
            +
                goto done;
         | 
| 202 | 
            +
             | 
| 203 | 
            +
            gerror:
         | 
| 204 | 
            +
                raise_rerror(NULL, _gerr);
         | 
| 205 | 
            +
            done:
         | 
| 206 | 
            +
                g_bytes_unref(args.data);
         | 
| 207 | 
            +
                return (Qnil);
         | 
| 208 | 
            +
            }
         | 
| 209 | 
            +
             | 
| 210 | 
            +
            void	define_Script()
         | 
| 211 | 
            +
            {
         | 
| 212 | 
            +
                cScript = rb_define_class_under(mCFrida, "Script", cGObject);
         | 
| 213 | 
            +
             | 
| 214 | 
            +
                rb_define_method(cScript, "is_destroyed", Script_is_destroyed, 0);
         | 
| 215 | 
            +
                rb_define_method(cScript, "load", Script_load, 0);
         | 
| 216 | 
            +
                rb_define_method(cScript, "unload", Script_unload, 0);
         | 
| 217 | 
            +
                rb_define_method(cScript, "eternalize", Script_eternalize, 0);
         | 
| 218 | 
            +
                rb_define_method(cScript, "enable_debugger", Script_enable_debugger, -1);
         | 
| 219 | 
            +
                rb_define_method(cScript, "disable_debugger", Script_disable_debugger, 0);
         | 
| 220 | 
            +
                rb_define_method(cScript, "post", Script_post, -1);
         | 
| 221 | 
            +
            }
         |