@@ -88,17 +88,25 @@ def _to_envp(value):
8888
8989def _make_options(cls, values, selectors):
9090 options = cls()
91+ _apply_settings(options, values, selectors)
92+ return options
93+
94+
95+ def _apply_settings(impl, values, selectors):
9196 for name, value in values.items():
9297 if value is None:
9398 continue
9499 select = selectors.get(name)
95100 if select is None:
96- setattr(options, name, value)
101+ setattr(impl, name, _unwrap(value))
102+ elif isinstance(value, dict):
103+ add = getattr(impl, select)
104+ for key, element in value.items():
105+ add(key, _unwrap(element))
97106 else:
98- add = getattr(options , select)
107+ add = getattr(impl , select)
99108 for element in value:
100- add(element)
101- return options
109+ add(_unwrap(element))
102110
103111
104112_current_cancellable = threading.local()
@@ -182,17 +190,25 @@ def _to_envp(value):
182190
183191def _make_options(cls, values, selectors):
184192 options = cls()
193+ _apply_settings(options, values, selectors)
194+ return options
195+
196+
197+ def _apply_settings(impl, values, selectors):
185198 for name, value in values.items():
186199 if value is None:
187200 continue
188201 select = selectors.get(name)
189202 if select is None:
190- setattr(options, name, value)
203+ setattr(impl, name, _unwrap(value))
204+ elif isinstance(value, dict):
205+ add = getattr(impl, select)
206+ for key, element in value.items():
207+ add(key, _unwrap(element))
191208 else:
192- add = getattr(options , select)
209+ add = getattr(impl , select)
193210 for element in value:
194- add(element)
195- return options
211+ add(_unwrap(element))
196212
197213
198214_current_cancellable: contextvars.ContextVar = contextvars.ContextVar("frida_current_cancellable", default=None)
@@ -516,10 +532,8 @@ def generate_facade_init(otype: ObjectType) -> str:
516532{ body } """
517533
518534 return f""" def __init__(self, *args, **kwargs):
519- self._impl = _frida.{ otype .py_name } (
520- *[_unwrap(a) for a in args],
521- **{{k: _unwrap(v) for k, v in kwargs.items()}},
522- )
535+ self._impl = _frida.{ otype .py_name } (*[_unwrap(a) for a in args])
536+ _apply_settings(self._impl, kwargs, { build_option_selectors (otype )} )
523537 setup = getattr(self, "_setup", None)
524538 if setup is not None:
525539 setup()"""
@@ -643,7 +657,7 @@ def generate_py_sync_method(method: Method, model: Model) -> Optional[str]:
643657 return None
644658
645659 params = [facade_param (param , model ) for param in method .input_parameters ]
646- names = ", " .join (param . name for param in method .input_parameters )
660+ names = ", " .join (facade_argument ( param , model ) for param in method .input_parameters )
647661
648662 call = f"self._impl.{ method .name } ({ names } )"
649663 if method .return_value is not None :
@@ -659,6 +673,12 @@ def facade_signature(method: Method, params: List[str]) -> str:
659673 return ", " .join (["self" ] + (method .custom_facade_params or params ))
660674
661675
676+ def facade_argument (param , model : Model ) -> str :
677+ if resolve_input_object_type (param .type , model ) is not None :
678+ return f"_unwrap({ param .name } )"
679+ return param .name
680+
681+
662682def facade_param (param , model : Model ) -> str :
663683 annotation = pyi_type (param .type , model )
664684 if param .nullable :
@@ -1839,6 +1859,16 @@ def build_sync_param(param: Parameter) -> Optional["SyncParam"]:
18391859 cleanup = f"g_clear_pointer (&{ name } , g_variant_unref);" ,
18401860 )
18411861
1862+ if resolve_input_object_type (param .type , param .object_type .model ) is not None :
1863+ return SyncParam (
1864+ decl = f"PyObject * { name } _obj;\n { param .type .c } { name } = NULL;" ,
1865+ fmt = "O" ,
1866+ parse_args = [f"&{ name } _obj" ],
1867+ pre = f"""if ({ name } _obj != Py_None)
1868+ { name } = ({ param .type .c } ) PY_GOBJECT_HANDLE ({ name } _obj);""" ,
1869+ call_arg = name ,
1870+ )
1871+
18421872 return None
18431873
18441874
0 commit comments