Class: CFrida::Session
- Inherits:
-
GObject
- Object
- GObject
- CFrida::Session
- Defined in:
- ext/c_frida/Session.c
Instance Method Summary collapse
- #compile_script(*args) ⇒ Object
- #create_script(*args) ⇒ Object
- #create_script_from_bytes(*args) ⇒ Object
- #detach ⇒ Object
- #disable_child_gating ⇒ Object
- #enable_child_gating ⇒ Object
- #inspect ⇒ Object (also: #to_s)
- #is_detached ⇒ Object
- #join_portal(*args) ⇒ Object
- #pid ⇒ Object
- #resume ⇒ Object
- #setup_peer_connection(*args) ⇒ Object
- #snapshot_script(*args) ⇒ Object
Instance Method Details
#compile_script(*args) ⇒ Object
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 |
# File 'ext/c_frida/Session.c', line 318
static VALUE Session_compile_script(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
FridaScriptOptions *options;
VALUE source, kws;
rb_scan_args(argc, argv, "1:", &source, &kws);
if (!RB_TYPE_P(source, T_STRING)) {
raise_argerror("source must be a string.");
return (Qnil);
}
options = frida_script_options_new();
if (!NIL_P(kws)) {
VALUE name = rb_hash_aref(kws, ID2SYM(rb_intern("name")));
if (!NIL_P(name)) {
if (!RB_TYPE_P(name, T_STRING)) {
raise_argerror("name must be a string.");
goto invalid_arg;
}
frida_script_options_set_name(options, StringValueCStr(name));
}
VALUE rruntime = rb_hash_aref(kws, ID2SYM(rb_intern("runtime")));
if (!NIL_P(rruntime)) {
if (!RB_TYPE_P(rruntime, T_STRING)) {
raise_argerror("runtime must be a string.");
goto invalid_arg;
}
FridaScriptRuntime runtime;
if (!rbGObject_unmarshal_enum(StringValueCStr(rruntime), FRIDA_TYPE_SCRIPT_RUNTIME, &runtime)) {
raise_argerror("runtime is invalid.");
goto invalid_arg;
}
frida_script_options_set_runtime(options, runtime);
}
}
compile_script_sync_proxy_args args = {
.handle = d->handle,
.source = StringValueCStr(source),
.options = options
};
CALL_GVL_FREE_WITH_RET(GBytes *result_bytes, compile_script_sync, &args);
g_clear_object(&options);
VALUE rresult = rbGObject_marshal_bytes(result_bytes);
g_bytes_unref(result_bytes);
return (rresult);
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
invalid_arg:
g_object_unref(options);
return (Qnil);
}
|
#create_script(*args) ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'ext/c_frida/Session.c', line 165
static VALUE Session_create_script(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
VALUE source, kws;
rb_scan_args(argc, argv, "1:", &source, &kws);
if (!RB_TYPE_P(source, T_STRING)) {
raise_argerror("source must be a string.");
return (Qnil);
}
FridaScriptOptions *options = frida_script_options_new();
if (!NIL_P(kws)) {
VALUE name = rb_hash_aref(kws, ID2SYM(rb_intern("name")));
if (!NIL_P(name)) {
if (!RB_TYPE_P(name, T_STRING)) {
raise_argerror("name must be a string.");
return (Qnil);
}
frida_script_options_set_name(options, StringValueCStr(name));
}
VALUE snapshot = rb_hash_aref(kws, ID2SYM(rb_intern("snapshot")));
if (!NIL_P(snapshot)) {
if (!RB_TYPE_P(snapshot, T_STRING)) {
raise_argerror("snapshot must be a string.");
return (g_object_unref(options), Qnil);
}
GBytes *gsnapshot = g_bytes_new(RSTRING_PTR(snapshot), RSTRING_LEN(snapshot));
frida_script_options_set_snapshot(options, gsnapshot);
}
VALUE runtime = rb_hash_aref(kws, ID2SYM(rb_intern("runtime")));
if (!NIL_P(runtime)) {
if (!RB_TYPE_P(runtime, T_STRING)) {
raise_argerror("runtime must be a string.");
return (g_object_unref(options), Qnil);
}
FridaScriptRuntime gruntime;
if (!rbGObject_unmarshal_enum(StringValueCStr(runtime), FRIDA_TYPE_SCRIPT_RUNTIME, &gruntime)) {
raise_argerror("invalid runtime.");
return (g_object_unref(options), Qnil);
}
frida_script_options_set_runtime(options, gruntime);
}
}
create_script_sync_proxy_args args = {
.handle = d->handle,
.source = StringValueCStr(source),
.options = options
};
CALL_GVL_FREE_WITH_RET(FridaScript *script, create_script_sync, &args);
g_clear_object(&options);
return (Script_from_FridaScript(script));
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
}
|
#create_script_from_bytes(*args) ⇒ Object
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 |
# File 'ext/c_frida/Session.c', line 237
static VALUE Session_create_script_from_bytes(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
FridaScriptOptions *options;
GBytes *cdata;
VALUE data, kws;
rb_scan_args(argc, argv, "1:", &data, &kws);
if (!RB_TYPE_P(data, T_STRING)) {
raise_argerror("data must be a string.");
return (Qnil);
}
cdata = g_bytes_new(RSTRING_PTR(data), RSTRING_LEN(data));
options = frida_script_options_new();
if (!NIL_P(kws)) {
VALUE name = rb_hash_aref(kws, ID2SYM(rb_intern("name")));
if (!NIL_P(name)) {
if (!RB_TYPE_P(name, T_STRING)) {
raise_argerror("name must be a string.");
goto invalid_arg;
}
frida_script_options_set_name(options, StringValueCStr(name));
}
VALUE snapshot = rb_hash_aref(kws, ID2SYM(rb_intern("snapshot")));
if (!NIL_P(snapshot)) {
if (!RB_TYPE_P(snapshot, T_STRING)) {
raise_argerror("snapshot must be a string.");
goto invalid_arg;
}
GBytes *csnapshot = g_bytes_new(RSTRING_PTR(snapshot), RSTRING_LEN(snapshot));
frida_script_options_set_snapshot(options, csnapshot);
g_bytes_unref(csnapshot);
}
VALUE rruntime = rb_hash_aref(kws, ID2SYM(rb_intern("runtime")));
if (!NIL_P(rruntime)) {
if (!RB_TYPE_P(rruntime, T_STRING)) {
raise_argerror("runtime must be a string.");
goto invalid_arg;
}
FridaScriptRuntime runtime;
if (!rbGObject_unmarshal_enum(StringValueCStr(rruntime), FRIDA_TYPE_SCRIPT_RUNTIME, &runtime)) {
raise_argerror("runtime is invalid.");
goto invalid_arg;
}
frida_script_options_set_runtime(options, runtime);
}
}
create_script_from_bytes_sync_proxy_args args = {
.handle = d->handle,
.bytes = cdata,
.options = options
};
CALL_GVL_FREE_WITH_RET(FridaScript *script, create_script_from_bytes_sync, &args);
g_bytes_unref(cdata);
g_clear_object(&options);
return (Script_from_FridaScript(script));
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
invalid_arg:
g_object_unref(options);
g_bytes_unref(cdata);
return (Qnil);
}
|
#detach ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'ext/c_frida/Session.c', line 46
static VALUE Session_detach(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
CALL_GVL_FREE_WITH_RET(void *dummy, detach_sync, d->handle);
goto done;
gerror:
raise_rerror(NULL, _gerr);
done:
return (Qnil);
}
|
#disable_child_gating ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'ext/c_frida/Session.c', line 138
static VALUE Session_disable_child_gating(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
CALL_GVL_FREE_WITH_RET(void *dummy, disable_child_gating_sync, d->handle);
goto done;
gerror:
raise_rerror(NULL, _gerr);
done:
return (Qnil);
}
|
#enable_child_gating ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'ext/c_frida/Session.c', line 112
static VALUE Session_enable_child_gating(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
CALL_GVL_FREE_WITH_RET(void *dummy, enable_child_gating_sync, d->handle);
goto done;
gerror:
raise_rerror(NULL, _gerr);
done:
return (Qnil);
}
|
#inspect ⇒ Object Also known as: to_s
17 18 19 20 21 22 23 |
# File 'ext/c_frida/Session.c', line 17
static VALUE Session_inspect(VALUE self)
{
VALUE s;
s = rb_sprintf("#<Session: pid=%+"PRIsVALUE">", rb_funcall(self, rb_intern("pid"), 0, NULL));
return (s);
}
|
#is_detached ⇒ Object
90 91 92 93 94 95 96 97 98 |
# File 'ext/c_frida/Session.c', line 90
static VALUE Session_is_detached(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
void *is_detached;
is_detached = rb_thread_call_without_gvl((void_fp)frida_session_is_detached, d->handle, NULL, NULL);
return (is_detached ? Qtrue : Qfalse);
}
|
#join_portal(*args) ⇒ Object
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 |
# File 'ext/c_frida/Session.c', line 540
static VALUE Session_join_portal(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
FridaPortalOptions *options;
VALUE kws, address, certificate, token, acl;
rb_scan_args(argc, argv, "1:", &address, &kws);
if (!RB_TYPE_P(address, T_STRING)) {
raise_argerror("address must be a string.");
return (Qnil);
}
options = frida_portal_options_new();
if (!NIL_P(kws)) {
certificate = rb_hash_aref(kws, ID2SYM(rb_intern("certificate")));
if (!NIL_P(certificate)) {
if (!RB_TYPE_P(certificate, T_STRING)) {
raise_argerror("certificate must be a string.");
goto invalid_arg;
}
GTlsCertificate *gcertificate;
if (!rbGObject_unmarshal_certificate(StringValueCStr(certificate), &gcertificate)) {
raise_argerror("invalid certificate.");
goto invalid_arg;
}
frida_portal_options_set_certificate(options, gcertificate);
g_object_unref(gcertificate);
}
token = rb_hash_aref(kws, ID2SYM(rb_intern("token")));
if (!NIL_P(token)) {
if (!RB_TYPE_P(token, T_STRING)) {
raise_argerror("token must be a string.");
goto invalid_arg;
}
frida_portal_options_set_token(options, StringValueCStr(token));
}
acl = rb_hash_aref(kws, ID2SYM(rb_intern("acl")));
if (!NIL_P(acl)) {
if (!RB_TYPE_P(acl, T_ARRAY) || !array_all_type(acl, T_STRING)) {
raise_argerror("acl must be an array of strings.");
goto invalid_arg;
}
gchar **c_acl;
gint acl_count;
rbGObject_unmarshal_strv(acl, &c_acl, &acl_count);
frida_portal_options_set_acl(options, c_acl, acl_count);
g_strfreev(c_acl);
}
}
join_portal_sync_proxy_args args = {
.handle = d->handle,
.address = StringValueCStr(address),
.options = options
};
CALL_GVL_FREE_WITH_RET(FridaPortalMembership *handle, join_portal_sync, &args);
g_object_unref(options);
return (PortalMembership_from_FridaPortalMembership(handle));
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
invalid_arg:
g_object_unref(options);
return (Qnil);
}
|
#pid ⇒ Object
29 30 31 32 |
# File 'ext/c_frida/Session.c', line 29
static VALUE Session_pid(VALUE self)
{
return (rb_ivar_get(self, rb_intern("pid")));
}
|
#resume ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'ext/c_frida/Session.c', line 72
static VALUE Session_resume(VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
CALL_GVL_FREE_WITH_RET(void *dummy, resume_sync, d->handle);
goto done;
gerror:
raise_rerror(NULL, _gerr);
done:
return (Qnil);
}
|
#setup_peer_connection(*args) ⇒ Object
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'ext/c_frida/Session.c', line 466
static VALUE Session_setup_peer_connection(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
FridaPeerOptions *options;
VALUE kws, stun_server, relays;
options = frida_peer_options_new();
rb_scan_args(argc, argv, ":", &kws);
if (!NIL_P(kws)) {
stun_server = rb_hash_aref(kws, ID2SYM(rb_intern("stun_server")));
if (!NIL_P(stun_server)) {
if (!RB_TYPE_P(stun_server, T_STRING)) {
raise_argerror("stun_server must be a string.");
goto invalid_arg;
}
frida_peer_options_set_stun_server(options, StringValueCStr(stun_server));
} else {
raise_argerror("expected stun_server.");
goto invalid_arg;
}
relays = rb_hash_aref(kws, ID2SYM(rb_intern("relays")));
if (!NIL_P(relays)) {
if (!RB_TYPE_P(relays, T_ARRAY) || !array_all_instance_of(relays, cRelay)) {
raise_argerror("relays must be an array of Relay.");
goto invalid_arg;
}
GObject_d *relay_data;
uint relays_count = RARRAY_LEN(relays);
for (uint i = 0; i < relays_count; i++) {
TypedData_Get_Struct(RARRAY_AREF(relays, i), GObject_d, &GObject_dt, relay_data);
if (!relay_data->handle) {
raise_argerror("provided an invalid Relay object.");
goto invalid_arg;
}
frida_peer_options_add_relay(options, relay_data->handle);
}
} else {
raise_argerror("expected relays array.");
goto invalid_arg;
}
} else {
raise_argerror("expected stun_server and relays.");
goto invalid_arg;
}
setup_peer_connection_sync_proxy_args args = {
.handle = d->handle,
.options = options
};
CALL_GVL_FREE_WITH_RET(void *dummy, setup_peer_connection_sync, &args);
g_clear_object(&options);
return (Qnil);
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
invalid_arg:
g_object_unref(options);
return (Qnil);
}
|
#snapshot_script(*args) ⇒ Object
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 |
# File 'ext/c_frida/Session.c', line 387
static VALUE Session_snapshot_script(int argc, VALUE *argv, VALUE self)
{
GET_GOBJECT_DATA();
REQUIRE_GOBJECT_HANDLE();
FridaSnapshotOptions *options;
VALUE embed_script, kws;
rb_scan_args(argc, argv, "1:", &embed_script, &kws);
if (!RB_TYPE_P(embed_script, T_STRING)) {
raise_argerror("embed_script must be a string.");
return (Qnil);
}
options = frida_snapshot_options_new();
if (!NIL_P(kws)) {
VALUE warmup_script = rb_hash_aref(kws, ID2SYM(rb_intern("warmup_script")));
if (!NIL_P(warmup_script)) {
if (!RB_TYPE_P(warmup_script, T_STRING)) {
raise_argerror("warmup_script must be a string.");
goto invalid_arg;
}
frida_snapshot_options_set_warmup_script(options, StringValueCStr(warmup_script));
}
VALUE rruntime = rb_hash_aref(kws, ID2SYM(rb_intern("runtime")));
if (!NIL_P(rruntime)) {
if (!RB_TYPE_P(rruntime, T_STRING)) {
raise_argerror("runtime must be a string.");
goto invalid_arg;
}
FridaScriptRuntime runtime;
if (!rbGObject_unmarshal_enum(StringValueCStr(rruntime), FRIDA_TYPE_SCRIPT_RUNTIME, &runtime)) {
raise_argerror("runtime is invalid.");
goto invalid_arg;
}
frida_snapshot_options_set_runtime(options, runtime);
}
}
snapshot_script_sync_proxy_args args = {
.handle = d->handle,
.embed_script = StringValueCStr(embed_script),
.options = options
};
CALL_GVL_FREE_WITH_RET(GBytes *result_bytes, snapshot_script_sync, &args);
g_clear_object(&options);
VALUE rresult = rbGObject_marshal_bytes(result_bytes);
g_bytes_unref(result_bytes);
return (rresult);
gerror:
g_clear_object(&options);
raise_rerror(NULL, _gerr);
return (Qnil);
invalid_arg:
g_object_unref(options);
return (Qnil);
}
|