def _complete_input(self, ctxt, text, state): try: if not isinstance(text, str): text = text.decode("charmap") return ctypes.cast(binaryninja.cstr(self.perform_complete_input(text, state)), ctypes.c_void_p).value except: log.log_error(traceback.format_exc()) return ctypes.cast(binaryninja.cstr(""), ctypes.c_void_p).value
def __init__(self, contents="", handle=None): if handle is not None: self.handle = core.handle_of_type(handle, core.BNDataBuffer) elif isinstance(contents, int) or isinstance(contents, numbers.Integral): self.handle = core.BNCreateDataBuffer(None, contents) elif isinstance(contents, DataBuffer): self.handle = core.BNDuplicateDataBuffer(contents.handle) else: if isinstance(contents, bytes) or isinstance( contents, bytearray) or isinstance(contents, str): contents = cstr(contents) else: raise TypeError( "DataBuffer contents must be bytes, bytearray, or str") self.handle = core.BNCreateDataBuffer(contents, len(contents))