Skip to content

Commit 3e489df

Browse files
committed
device: Add unpair()
1 parent 1d35663 commit 3e489df

File tree

4 files changed

+34
-1
lines changed

4 files changed

+34
-1
lines changed

_frida/__init__.pyi

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,11 @@ class Device(Object):
299299
Open a device-specific communication channel.
300300
"""
301301
...
302+
def unpair(self) -> None:
303+
"""
304+
Unpair device.
305+
"""
306+
...
302307
def query_system_parameters(self) -> Dict[str, Any]:
303308
"""
304309
Returns a dictionary of information about the host system.

examples/unpair.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import frida
2+
3+
device = frida.get_usb_device()
4+
device.unpair()

frida/core.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1035,6 +1035,14 @@ def open_channel(self, address: str) -> IOStream:
10351035

10361036
return IOStream(self._impl.open_channel(address))
10371037

1038+
@cancellable
1039+
def unpair(self) -> None:
1040+
"""
1041+
Unpair device
1042+
"""
1043+
1044+
self._impl.unpair()
1045+
10381046
@cancellable
10391047
def get_bus(self) -> Bus:
10401048
"""

src/_frida.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2013-2022 Ole André Vadla Ravnås <oleavr@nowsecure.com>
2+
* Copyright (C) 2013-2023 Ole André Vadla Ravnås <oleavr@nowsecure.com>
33
*
44
* Licence: wxWindows Library Licence, Version 3.1
55
*/
@@ -389,6 +389,7 @@ static FridaSessionOptions * PyDevice_parse_session_options (const gchar * realm
389389
static PyObject * PyDevice_inject_library_file (PyDevice * self, PyObject * args);
390390
static PyObject * PyDevice_inject_library_blob (PyDevice * self, PyObject * args);
391391
static PyObject * PyDevice_open_channel (PyDevice * self, PyObject * args);
392+
static PyObject * PyDevice_unpair (PyDevice * self);
392393

393394
static PyObject * PyApplication_new_take_handle (FridaApplication * handle);
394395
static int PyApplication_init (PyApplication * self, PyObject * args, PyObject * kw);
@@ -565,6 +566,7 @@ static PyMethodDef PyDevice_methods[] =
565566
{ "inject_library_file", (PyCFunction) PyDevice_inject_library_file, METH_VARARGS, "Inject a library file to a PID." },
566567
{ "inject_library_blob", (PyCFunction) PyDevice_inject_library_blob, METH_VARARGS, "Inject a library blob to a PID." },
567568
{ "open_channel", (PyCFunction) PyDevice_open_channel, METH_VARARGS, "Open a device-specific communication channel." },
569+
{ "unpair", (PyCFunction) PyDevice_unpair, METH_NOARGS, "Unpair device." },
568570
{ NULL }
569571
};
570572

@@ -2835,6 +2837,20 @@ PyDevice_open_channel (PyDevice * self, PyObject * args)
28352837
return PyIOStream_new_take_handle (stream);
28362838
}
28372839

2840+
static PyObject *
2841+
PyDevice_unpair (PyDevice * self)
2842+
{
2843+
GError * error = NULL;
2844+
2845+
Py_BEGIN_ALLOW_THREADS
2846+
frida_device_unpair_sync (PY_GOBJECT_HANDLE (self), g_cancellable_get_current (), &error);
2847+
Py_END_ALLOW_THREADS
2848+
if (error != NULL)
2849+
return PyFrida_raise (error);
2850+
2851+
Py_RETURN_NONE;
2852+
}
2853+
28382854

28392855
static PyObject *
28402856
PyApplication_new_take_handle (FridaApplication * handle)

0 commit comments

Comments
 (0)