mirror of
https://github.com/frida/frida-python.git
synced 2026-11-07 09:35:57 -10:00
Format with the current Black
Black has changed how it lays out a call whose argument is a multiline string, and a `with` statement holding several contexts.
This commit is contained in:
1 parent
01fd680353
commit
8f31efacf2
5 files changed
+28
-14
No files matched your search
@@ -42,7 +42,8 @@ class Application:
|
||||
print("✔ enable_child_gating()")
|
||||
session.enable_child_gating()
|
||||
print("✔ create_script()")
|
||||
script = session.create_script("""\
|
||||
script = session.create_script(
|
||||
"""\
|
||||
Interceptor.attach(Module.getGlobalExportByName('open'), {
|
||||
onEnter(args) {
|
||||
send({
|
||||
@@ -51,7 +52,8 @@ Interceptor.attach(Module.getGlobalExportByName('open'), {
|
||||
});
|
||||
}
|
||||
});
|
||||
""")
|
||||
"""
|
||||
)
|
||||
script.on("message", lambda message, data: self._reactor.schedule(lambda: self._on_message(pid, message)))
|
||||
print("✔ load()")
|
||||
script.load()
|
||||
|
||||
+4
-2
@@ -1,7 +1,8 @@
|
||||
import frida
|
||||
|
||||
session = frida.attach("Twitter")
|
||||
script = session.create_script("""\
|
||||
script = session.create_script(
|
||||
"""\
|
||||
rpc.exports = {
|
||||
hello: function () {
|
||||
return 'Hello';
|
||||
@@ -10,7 +11,8 @@ rpc.exports = {
|
||||
oops;
|
||||
}
|
||||
};
|
||||
""")
|
||||
"""
|
||||
)
|
||||
script.load()
|
||||
api = script.exports_sync
|
||||
print("api.hello() =>", api.hello())
|
||||
|
||||
@@ -22,7 +22,8 @@ class Application:
|
||||
self._session = session
|
||||
session.on("detached", lambda *args: self._reactor.schedule(lambda: self._on_detached(*args)))
|
||||
|
||||
script = session.create_script("""
|
||||
script = session.create_script(
|
||||
"""
|
||||
let _puts = null;
|
||||
|
||||
Interceptor.attach(DebugSymbol.getFunctionByName('f'), {
|
||||
@@ -47,7 +48,8 @@ function puts(s) {
|
||||
}
|
||||
_puts(Memory.allocUtf8String(s));
|
||||
}
|
||||
""")
|
||||
"""
|
||||
)
|
||||
self._script = script
|
||||
script.on("message", lambda *args: self._reactor.schedule(lambda: self._on_message(*args)))
|
||||
script.load()
|
||||
|
||||
@@ -29,7 +29,8 @@ class Application:
|
||||
session = self._device.attach(pid)
|
||||
session.on("detached", lambda reason: self._reactor.schedule(lambda: self._on_detached(pid, session, reason)))
|
||||
print("✔ create_script()")
|
||||
script = session.create_script("""\
|
||||
script = session.create_script(
|
||||
"""\
|
||||
const puts = new NativeFunction(Module.getGlobalExportByName('puts'), 'int', ['pointer']);
|
||||
puts(Memory.allocUtf8String('Hello from Frida agent'));
|
||||
Interceptor.attach(Module.getGlobalExportByName('open'), {
|
||||
@@ -40,7 +41,8 @@ Interceptor.attach(Module.getGlobalExportByName('open'), {
|
||||
});
|
||||
}
|
||||
});
|
||||
""")
|
||||
"""
|
||||
)
|
||||
script.on("message", lambda message, data: self._reactor.schedule(lambda: self._on_message(pid, message)))
|
||||
print("✔ load()")
|
||||
script.load()
|
||||
|
||||
@@ -1303,13 +1303,15 @@ def generate_object_type_toplevel_definitions(model: Model) -> str:
|
||||
cprefix = otype.c_symbol_prefix
|
||||
|
||||
if otype.name == "Object":
|
||||
defs.append(f"""PYFRIDA_DEFINE_BASETYPE ("_frida.{otype.py_name}", {otype.py_name}, g_object_unref,
|
||||
defs.append(
|
||||
f"""PYFRIDA_DEFINE_BASETYPE ("_frida.{otype.py_name}", {otype.py_name}, g_object_unref,
|
||||
{{ Py_tp_doc, "{otype.name}" }},
|
||||
{{ Py_tp_init, {cprefix}_init }},
|
||||
{{ Py_tp_dealloc, {cprefix}_dealloc }},
|
||||
{{ Py_tp_methods, {cprefix}_methods }},
|
||||
{{ Py_tp_getset, {cprefix}_getsets }},
|
||||
);""")
|
||||
);"""
|
||||
)
|
||||
continue
|
||||
|
||||
parent = otype.parent
|
||||
@@ -1329,12 +1331,14 @@ def generate_object_type_toplevel_definitions(model: Model) -> str:
|
||||
)
|
||||
continue
|
||||
|
||||
defs.append(f"""PYFRIDA_DEFINE_TYPE ("_frida.{otype.py_name}", {otype.py_name}, {parent_name}, g_object_unref,
|
||||
defs.append(
|
||||
f"""PYFRIDA_DEFINE_TYPE ("_frida.{otype.py_name}", {otype.py_name}, {parent_name}, g_object_unref,
|
||||
{{ Py_tp_doc, "{otype.name}" }},
|
||||
{{ Py_tp_init, {cprefix}_init }},
|
||||
{{ Py_tp_methods, {cprefix}_methods }},
|
||||
{{ Py_tp_getset, {cprefix}_getsets }},
|
||||
);""")
|
||||
);"""
|
||||
)
|
||||
|
||||
return "\n\n".join(defs)
|
||||
|
||||
@@ -2764,10 +2768,12 @@ def generate_object_type_structs(model: Model) -> str:
|
||||
for otype in model.regular_object_types:
|
||||
if otype.name == "Object":
|
||||
continue
|
||||
structs.append(f"""struct _{otype.c_symbol_prefix}
|
||||
structs.append(
|
||||
f"""struct _{otype.c_symbol_prefix}
|
||||
{{
|
||||
{otype.parent_c_symbol_prefix} parent;
|
||||
}};""")
|
||||
}};"""
|
||||
)
|
||||
|
||||
return "\n\n".join(structs)
|
||||
|
||||
|
||||
Reference in new issue
Block a user