diff options
| author | Rusty Wagner <rusty@vector35.com> | 2016-07-22 03:00:52 -0400 |
|---|---|---|
| committer | Rusty Wagner <rusty@vector35.com> | 2016-07-22 03:00:52 -0400 |
| commit | 13491e5eb8d50c242cf6858b111e404ea9f79239 (patch) | |
| tree | 653ea1b2267ef67c1f8442516a0d9286e8fdf1ad /python | |
| parent | 5e15a16c95dd3e0b48ea0b319a813720f14fec5a (diff) | |
Add API to set type of function
Diffstat (limited to 'python')
| -rw-r--r-- | python/__init__.py | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/python/__init__.py b/python/__init__.py index fd4af520..9f090c2f 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -1733,6 +1733,18 @@ class BinaryView(object): return iter(LinearDisassemblyIterator(self, settings)) + def parse_type_string(self, text): + result = core.BNNameAndType() + errors = ctypes.c_char_p() + if not core.BNParseTypeString(self.handle, text, result, errors): + error_str = errors.value + core.BNFreeString(ctypes.cast(errors, ctypes.POINTER(ctypes.c_byte))) + raise SyntaxError, error_str + type_obj = Type(core.BNNewTypeReference(result.type)) + name = result.name + core.BNFreeNameAndType(result) + return type_obj, name + def __setattr__(self, name, value): try: object.__setattr__(self,name,value) @@ -2523,10 +2535,14 @@ class Function(object): core.BNGetFunctionLiftedIL(self.handle)), self) @property - def type(self): - """Function type (read-only)""" + def function_type(self): + """Function type""" return Type(core.BNGetFunctionType(self.handle)) + @function_type.setter + def function_type(self, value): + self.set_user_type(value) + @property def stack_layout(self): """List of function stack (read-only)""" @@ -2783,6 +2799,12 @@ class Function(object): core.BNFreeInstructionTextLines(lines, count.value) return result + def set_auto_type(self, value): + core.BNSetFunctionAutoType(self.handle, value.handle) + + def set_user_type(self, value): + core.BNSetFunctionUserType(self.handle, value.handle) + class BasicBlockEdge: def __init__(self, branch_type, target, arch): self.type = core.BNBranchType_names[branch_type] |
