mirror of
https://github.com/frida/frida-python
synced 2026-06-08 14:16:17 +00:00
Add Device.get_frontmost_application()
This commit is contained in:
@@ -140,6 +140,7 @@ static PyObject * PyDevice_from_handle (FridaDevice * handle);
|
||||
static int PyDevice_init (PyDevice * self);
|
||||
static void PyDevice_dealloc (PyDevice * self);
|
||||
static PyObject * PyDevice_repr (PyDevice * self);
|
||||
static PyObject * PyDevice_get_frontmost_application (PyDevice * self);
|
||||
static PyObject * PyDevice_enumerate_applications (PyDevice * self);
|
||||
static PyObject * PyDevice_enumerate_processes (PyDevice * self);
|
||||
static PyObject * PyDevice_spawn (PyDevice * self, PyObject * args);
|
||||
@@ -205,6 +206,7 @@ static PyMethodDef PyDeviceManager_methods[] =
|
||||
|
||||
static PyMethodDef PyDevice_methods[] =
|
||||
{
|
||||
{ "get_frontmost_application", (PyCFunction) PyDevice_get_frontmost_application, METH_NOARGS, "Get details about the frontmost application." },
|
||||
{ "enumerate_applications", (PyCFunction) PyDevice_enumerate_applications, METH_NOARGS, "Enumerate applications." },
|
||||
{ "enumerate_processes", (PyCFunction) PyDevice_enumerate_processes, METH_NOARGS, "Enumerate processes." },
|
||||
{ "spawn", (PyCFunction) PyDevice_spawn, METH_VARARGS, "Spawn a process into an attachable state." },
|
||||
@@ -802,6 +804,24 @@ PyDevice_repr (PyDevice * self)
|
||||
return PyRepr_FromFormat ("Device(id=%u, name=\"%s\", type='%s')", self->id, self->name, self->type);
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyDevice_get_frontmost_application (PyDevice * self)
|
||||
{
|
||||
GError * error = NULL;
|
||||
FridaApplication * result;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
result = frida_device_get_frontmost_application_sync (self->handle, &error);
|
||||
Py_END_ALLOW_THREADS
|
||||
if (error != NULL)
|
||||
return PyFrida_raise (error);
|
||||
|
||||
if (result != NULL)
|
||||
return PyApplication_from_handle (result);
|
||||
else
|
||||
Py_RETURN_NONE;
|
||||
}
|
||||
|
||||
static PyObject *
|
||||
PyDevice_enumerate_applications (PyDevice * self)
|
||||
{
|
||||
|
||||
@@ -45,6 +45,9 @@ class Device(object):
|
||||
def __repr__(self):
|
||||
return repr(self._impl)
|
||||
|
||||
def get_frontmost_application(self):
|
||||
return self._impl.get_frontmost_application()
|
||||
|
||||
def enumerate_applications(self):
|
||||
return self._impl.enumerate_applications()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user