def pointer(self, arch, t, const=None, volatile=None, ref_type=None): if const is None: const = BoolWithConfidence(False, confidence = 0) elif not isinstance(const, BoolWithConfidence): const = BoolWithConfidence(const) if volatile is None: volatile = BoolWithConfidence(False, confidence = 0) elif not isinstance(volatile, BoolWithConfidence): volatile = BoolWithConfidence(volatile) if ref_type is None: ref_type = ReferenceType.PointerReferenceType type_conf = core.BNTypeWithConfidence() type_conf.type = t.handle type_conf.confidence = t.confidence const_conf = core.BNBoolWithConfidence() const_conf.value = const.value const_conf.confidence = const.confidence volatile_conf = core.BNBoolWithConfidence() volatile_conf.value = volatile.value volatile_conf.confidence = volatile.confidence return Type(core.BNCreatePointerType(arch.handle, type_conf, const_conf, volatile_conf, ref_type))
def int(self, width, sign = None, altname=""): """ ``int`` class method for creating an int Type. :param int width: width of the integer in bytes :param bool sign: optional variable representing signedness """ if sign is None: sign = BoolWithConfidence(True, confidence = 0) elif not isinstance(sign, BoolWithConfidence): sign = BoolWithConfidence(sign) sign_conf = core.BNBoolWithConfidence() sign_conf.value = sign.value sign_conf.confidence = sign.confidence return Type(core.BNCreateIntegerType(width, sign_conf, altname))
def function(self, ret, params, calling_convention=None, variable_arguments=None, stack_adjust=None): """ ``function`` class method for creating an function Type. :param Type ret: width of the integer in bytes :param list(Type) params: list of parameter Types :param CallingConvention calling_convention: optional argument for function calling convention :param bool variable_arguments: optional argument for functions that have a variable number of arguments """ param_buf = (core.BNFunctionParameter * len(params))() for i in xrange(0, len(params)): if isinstance(params[i], Type): param_buf[i].name = "" param_buf[i].type = params[i].handle param_buf[i].typeConfidence = params[i].confidence param_buf[i].defaultLocation = True elif isinstance(params[i], FunctionParameter): param_buf[i].name = params[i].name param_buf[i].type = params[i].type.handle param_buf[i].typeConfidence = params[i].type.confidence if params[i].location is None: param_buf[i].defaultLocation = True else: param_buf[i].defaultLocation = False param_buf[i].location.type = params[i].location.type param_buf[i].location.index = params[i].location.index param_buf[i].location.storage = params[i].location.storage else: param_buf[i].name = params[i][1] param_buf[i].type = params[i][0].handle param_buf[i].typeConfidence = params[i][0].confidence param_buf[i].defaultLocation = True ret_conf = core.BNTypeWithConfidence() ret_conf.type = ret.handle ret_conf.confidence = ret.confidence conv_conf = core.BNCallingConventionWithConfidence() if calling_convention is None: conv_conf.convention = None conv_conf.confidence = 0 else: conv_conf.convention = calling_convention.handle conv_conf.confidence = calling_convention.confidence if variable_arguments is None: variable_arguments = BoolWithConfidence(False, confidence = 0) elif not isinstance(variable_arguments, BoolWithConfidence): variable_arguments = BoolWithConfidence(variable_arguments) vararg_conf = core.BNBoolWithConfidence() vararg_conf.value = variable_arguments.value vararg_conf.confidence = variable_arguments.confidence if stack_adjust is None: stack_adjust = SizeWithConfidence(0, confidence = 0) elif not isinstance(stack_adjust, SizeWithConfidence): stack_adjust = SizeWithConfidence(stack_adjust) stack_adjust_conf = core.BNSizeWithConfidence() stack_adjust_conf.value = stack_adjust.value stack_adjust_conf.confidence = stack_adjust.confidence return Type(core.BNCreateFunctionType(ret_conf, conv_conf, param_buf, len(params), vararg_conf, stack_adjust_conf))