mirror of
https://github.com/frida/frida-python.git
synced 2026-11-11 10:01:27 -10:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
082c9dfbc9 | ||
|
|
274c52291b | ||
|
|
b9e24033ed | ||
|
|
10aeb056c6 | ||
|
|
e5e0558250 | ||
|
|
cd74f3618a | ||
|
|
9fff6507af | ||
|
|
37badc7959 | ||
|
|
8b05045785 |
No files matched your search
@@ -70,10 +70,18 @@ def _to_envp(value):
|
||||
return value
|
||||
|
||||
|
||||
def _make_options(cls, values):
|
||||
def _make_options(cls, values, selectors):
|
||||
options = cls()
|
||||
for name, value in values.items():
|
||||
setattr(options, name, value)
|
||||
if value is None:
|
||||
continue
|
||||
select = selectors.get(name)
|
||||
if select is None:
|
||||
setattr(options, name, value)
|
||||
else:
|
||||
add = getattr(options, select)
|
||||
for element in value:
|
||||
add(element)
|
||||
return options
|
||||
|
||||
|
||||
@@ -156,10 +164,18 @@ def _to_envp(value):
|
||||
return value
|
||||
|
||||
|
||||
def _make_options(cls, values):
|
||||
def _make_options(cls, values, selectors):
|
||||
options = cls()
|
||||
for name, value in values.items():
|
||||
setattr(options, name, value)
|
||||
if value is None:
|
||||
continue
|
||||
select = selectors.get(name)
|
||||
if select is None:
|
||||
setattr(options, name, value)
|
||||
else:
|
||||
add = getattr(options, select)
|
||||
for element in value:
|
||||
add(element)
|
||||
return options
|
||||
|
||||
|
||||
@@ -575,7 +591,7 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
|
||||
options = resolve_options_type(param.type, model)
|
||||
if options is not None:
|
||||
signature.append("**kwargs")
|
||||
args.append(f"_make_options(_frida.{options.py_name}, kwargs)")
|
||||
args.append(f"_make_options(_frida.{options.py_name}, kwargs, {build_option_selectors(options)})")
|
||||
elif resolve_input_object_type(param.type, model) is not None:
|
||||
signature.append(f"{param.name}=None")
|
||||
args.append(f"_unwrap({param.name})")
|
||||
@@ -590,6 +606,17 @@ def build_facade_async_parts(method: Method, model: Model) -> Optional[Tuple[str
|
||||
return ", ".join(signature), "".join(arg + ", " for arg in args)
|
||||
|
||||
|
||||
def build_option_selectors(options: ObjectType) -> str:
|
||||
selectors = {}
|
||||
otype = options
|
||||
while otype is not None:
|
||||
for method in otype.methods:
|
||||
if method.is_select_method:
|
||||
selectors[method.select_plural_noun] = method.name
|
||||
otype = otype.parent
|
||||
return repr(selectors)
|
||||
|
||||
|
||||
def wrap_result(call: str, type: Type, model: Model) -> str:
|
||||
if resolve_object_type(type, model) is not None:
|
||||
return f"_wrap({call})"
|
||||
|
||||
@@ -120,8 +120,9 @@ if aux:
|
||||
"attach": MethodCustomizations(
|
||||
param_typings=["target", "**kwargs"],
|
||||
custom_logic=(
|
||||
"pid = self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs)",
|
||||
"pid = await self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs)",
|
||||
"pid = self._pid_of(target)\n" "options = _make_options(_frida.SessionOptions, kwargs, {})",
|
||||
"pid = await self._pid_of(target)\n"
|
||||
"options = _make_options(_frida.SessionOptions, kwargs, {})",
|
||||
),
|
||||
),
|
||||
},
|
||||
|
||||
@@ -107,6 +107,14 @@ class Method(core.Method):
|
||||
def operation_type_name(self) -> str:
|
||||
return f"Py{self.object_type.name}{to_pascal_case(self.name)}Operation"
|
||||
|
||||
@cached_property
|
||||
def is_select_method(self) -> bool:
|
||||
return self.name.startswith("select_") or self.name.startswith("add_")
|
||||
|
||||
@cached_property
|
||||
def select_plural_noun(self) -> str:
|
||||
return f"{self.name.split('_', maxsplit=1)[1]}s"
|
||||
|
||||
@cached_property
|
||||
def customizations(self) -> Optional[MethodCustomizations]:
|
||||
custom = self.object_type.customizations
|
||||
|
||||
+1
-1
Submodule releng updated: f3c2f0efbf...abb8238970.
@@ -1,6 +1,6 @@
|
||||
[wrap-git]
|
||||
url = https://github.com/frida/frida-core.git
|
||||
revision = 17.16.0
|
||||
revision = 17.16.3
|
||||
depth = 1
|
||||
|
||||
[provide]
|
||||
|
||||
Reference in new issue
Block a user