From 2421d9a6e6e86ff3f37056a68454b7437fb60860 Mon Sep 17 00:00:00 2001 From: Peter LaFosse Date: Mon, 2 Jan 2017 16:15:07 -0500 Subject: Manual merging with dev --- python/binaryview.py | 29 +++++- python/bntype.py | 18 ++-- python/examples/nsf.py | 138 +++++++++++++++++++++++++ python/lowlevelil.py | 267 +++++++++++++++++++++++++------------------------ 4 files changed, 307 insertions(+), 145 deletions(-) create mode 100644 python/examples/nsf.py (limited to 'python') diff --git a/python/binaryview.py b/python/binaryview.py index 7c85cd52..b4be159c 100644 --- a/python/binaryview.py +++ b/python/binaryview.py @@ -590,6 +590,16 @@ class BinaryView(object): @classmethod def set_default_session_data(cls, name, value): + """ + ```set_default_session_data``` saves a variable to the BinaryView. + :param name: name of the variable to be saved + :param value: value of the variable to be saved + + :Example: + >>> BinaryView.set_default_session_data("variable_name", "value") + >>> bv.session_data.variable_name + 'value' + """ _BinaryViewAssociatedDataStore.set_default(name, value) def __del__(self): @@ -1932,6 +1942,19 @@ class BinaryView(object): return basicblock.BasicBlock(self, block) def get_code_refs(self, addr, length=None): + """ + ``get_code_refs`` returns a list of ReferenceSource objects (xrefs or cross-references) that point to the provided virtual address. + + :param int addr: virtual address to query for references + :return: List of References for the given virtual address + :rtype: list(ReferenceSource) + :Example: + + >>> bv.get_code_refs(here) + [] + >>> + + """ count = ctypes.c_ulonglong(0) if length is None: refs = core.BNGetCodeReferences(self.handle, addr, count) @@ -3434,7 +3457,7 @@ class BinaryWriter(object): def write16(self, value): """ - ```` writes the lowest order two bytes from the integer ``value`` to the current offset, using internal endianness. + ``write16`` writes the lowest order two bytes from the integer ``value`` to the current offset, using internal endianness. :param int value: integer value to write. :return: boolean True on success, False on failure. @@ -3444,7 +3467,7 @@ class BinaryWriter(object): def write32(self, value): """ - ```` writes the lowest order four bytes from the integer ``value`` to the current offset, using internal endianness. + ``write32`` writes the lowest order four bytes from the integer ``value`` to the current offset, using internal endianness. :param int value: integer value to write. :return: boolean True on success, False on failure. @@ -3454,7 +3477,7 @@ class BinaryWriter(object): def write64(self, value): """ - ```` writes the lowest order eight bytes from the integer ``value`` to the current offset, using internal endianness. + ``write64`` writes the lowest order eight bytes from the integer ``value`` to the current offset, using internal endianness. :param int value: integer value to write. :return: boolean True on success, False on failure. diff --git a/python/bntype.py b/python/bntype.py index 9f070168..1822c5df 100644 --- a/python/bntype.py +++ b/python/bntype.py @@ -235,8 +235,8 @@ class Type(object): return Type(core.BNCreateBoolType()) @classmethod - def int(self, width, sign = True): - return Type(core.BNCreateIntegerType(width, sign)) + def int(self, width, sign = True, altname=""): + return Type(core.BNCreateIntegerType(width, sign, altname)) @classmethod def float(self, width): @@ -251,13 +251,13 @@ class Type(object): return Type(core.BNCreateUnknownType(unknown_type.handle)) @classmethod - def enumeration_type(self, arch, e, width = None): + def enumeration_type(self, arch, e, width=None): if width is None: width = arch.default_int_size return Type(core.BNCreateEnumerationType(e.handle, width)) @classmethod - def pointer(self, arch, t, const = False): + def pointer(self, arch, t, const=False): return Type(core.BNCreatePointerType(arch.handle, t.handle, const)) @classmethod @@ -265,7 +265,7 @@ class Type(object): return Type(core.BNCreateArrayType(t.handle, count)) @classmethod - def function(self, ret, params, calling_convention = None, variable_arguments = False): + def function(self, ret, params, calling_convention=None, variable_arguments=False): param_buf = (core.BNNameAndType * len(params))() for i in xrange(0, len(params)): if isinstance(params[i], Type): @@ -287,7 +287,7 @@ class Type(object): class UnknownType(object): - def __init__(self, handle = None): + def __init__(self, handle=None): if handle is None: self.handle = core.BNCreateUnknownType() else: @@ -324,7 +324,7 @@ class StructureMember(object): class Structure(object): - def __init__(self, handle = None): + def __init__(self, handle=None): if handle is None: self.handle = core.BNCreateStructure() else: @@ -416,7 +416,7 @@ class EnumerationMember(object): class Enumeration(object): - def __init__(self, handle = None): + def __init__(self, handle=None): if handle is None: self.handle = core.BNCreateEnumeration() else: @@ -472,7 +472,7 @@ class TypeParserResult(object): return "{types: %s, variables: %s, functions: %s}" % (self.types, self.variables, self.functions) -def preprocess_source(source, filename = None, include_dirs = []): +def preprocess_source(source, filename=None, include_dirs=[]): """ ``preprocess_source`` run the C preprocessor on the given source or source filename. diff --git a/python/examples/nsf.py b/python/examples/nsf.py new file mode 100644 index 00000000..9d4ebd5c --- /dev/null +++ b/python/examples/nsf.py @@ -0,0 +1,138 @@ +# Copyright (c) 2015-2016 Vector 35 LLC +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# +# Simple NSF file loader, primarily for analyzing: +# https://scarybeastsecurity.blogspot.com/2016/11/0day-exploit-compromising-linux-desktop.html +# + +from binaryninja import * +import struct +import traceback +import os + +class NSFView(BinaryView): + name = "NSF" + long_name = "Nintendo Sound Format" + + def __init__(self, data): + BinaryView.__init__(self, parent_view = data, file_metadata = data.file) + + @classmethod + def is_valid_for_data(self, data): + hdr = data.read(0, 128) + if len(hdr) < 128: + return False + if hdr[0:5] != "NESM\x1a": + return False + song_count = struct.unpack("B", hdr[6])[0] + if song_count < 1: + log_info("Appears to be an NSF, but no songs.") + return False + return True + + def init(self): + try: + hdr = self.parent_view.read(0, 128) + self.version = struct.unpack("B", hdr[5])[0] + self.song_count = struct.unpack("B", hdr[6])[0] + self.starting_song = struct.unpack("B", hdr[7])[0] + self.load_address = struct.unpack("{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ADD, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_ADD, a.index, b.index, size=size, flags=flags) - def add_carry(self, size, a, b, flags = None): + def add_carry(self, size, a, b, flags=None): """ ``add_carry`` adds with carry expression ``a`` to expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -518,9 +518,9 @@ class LowLevelILFunction(object): :return: The expression ``adc.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ADC, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_ADC, a.index, b.index, size=size, flags=flags) - def sub(self, size, a, b, flags = None): + def sub(self, size, a, b, flags=None): """ ``sub`` subtracts expression ``b`` from expression ``a`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -532,9 +532,9 @@ class LowLevelILFunction(object): :return: The expression ``sub.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_SUB, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_SUB, a.index, b.index, size=size, flags=flags) - def sub_borrow(self, size, a, b, flags = None): + def sub_borrow(self, size, a, b, flags=None): """ ``sub_borrow`` subtracts with borrow expression ``b`` from expression ``a`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -546,9 +546,9 @@ class LowLevelILFunction(object): :return: The expression ``sbc.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_SBB, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_SBB, a.index, b.index, size=size, flags=flags) - def and_expr(self, size, a, b, flags = None): + def and_expr(self, size, a, b, flags=None): """ ``and_expr`` bitwise and's expression ``a`` and expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -560,9 +560,9 @@ class LowLevelILFunction(object): :return: The expression ``and.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_AND, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_AND, a.index, b.index, size=size, flags=flags) - def or_expr(self, size, a, b, flags = None): + def or_expr(self, size, a, b, flags=None): """ ``or_expr`` bitwise or's expression ``a`` and expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -574,9 +574,9 @@ class LowLevelILFunction(object): :return: The expression ``or.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_OR, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_OR, a.index, b.index, size=size, flags=flags) - def xor_expr(self, size, a, b, flags = None): + def xor_expr(self, size, a, b, flags=None): """ ``xor_expr`` xor's expression ``a`` with expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -588,9 +588,9 @@ class LowLevelILFunction(object): :return: The expression ``xor.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_XOR, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_XOR, a.index, b.index, size=size, flags=flags) - def shift_left(self, size, a, b, flags = None): + def shift_left(self, size, a, b, flags=None): """ ``shift_left`` subtracts with borrow expression ``b`` from expression ``a`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -602,9 +602,9 @@ class LowLevelILFunction(object): :return: The expression ``lsl.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_LSL, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_LSL, a.index, b.index, size=size, flags=flags) - def logical_shift_right(self, size, a, b, flags = None): + def logical_shift_right(self, size, a, b, flags=None): """ ``logical_shift_right`` shifts logically right expression ``a`` by expression ``b`` potentially setting flags ``flags``and returning an expression of ``size`` bytes. @@ -616,9 +616,9 @@ class LowLevelILFunction(object): :return: The expression ``lsr.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_LSR, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_LSR, a.index, b.index, size=size, flags=flags) - def arith_shift_right(self, size, a, b, flags = None): + def arith_shift_right(self, size, a, b, flags=None): """ ``arith_shift_right`` shifts arithmatic right expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -630,9 +630,9 @@ class LowLevelILFunction(object): :return: The expression ``asr.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ASR, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_ASR, a.index, b.index, size=size, flags=flags) - def rotate_left(self, size, a, b, flags = None): + def rotate_left(self, size, a, b, flags=None): """ ``rotate_left`` bitwise rotates left expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -644,9 +644,9 @@ class LowLevelILFunction(object): :return: The expression ``rol.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ROL, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_ROL, a.index, b.index, size=size, flags=flags) - def rotate_left_carry(self, size, a, b, flags = None): + def rotate_left_carry(self, size, a, b, flags=None): """ ``rotate_left_carry`` bitwise rotates left with carry expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -658,9 +658,9 @@ class LowLevelILFunction(object): :return: The expression ``rcl.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.LLIL_RLC, a.index, b.index, size = size, flags = flags) + return self.expr(core.LLIL_RLC, a.index, b.index, size=size, flags=flags) - def rotate_right(self, size, a, b, flags = None): + def rotate_right(self, size, a, b, flags=None): """ ``rotate_right`` bitwise rotates right expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -672,9 +672,9 @@ class LowLevelILFunction(object): :return: The expression ``ror.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ROR, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_ROR, a.index, b.index, size=size, flags=flags) - def rotate_right_carry(self, size, a, b, flags = None): + def rotate_right_carry(self, size, a, b, flags=None): """ ``rotate_right_carry`` bitwise rotates right with carry expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -686,9 +686,9 @@ class LowLevelILFunction(object): :return: The expression ``rcr.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_RRC, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_RRC, a.index, b.index, size=size, flags=flags) - def mult(self, size, a, b, flags = None): + def mult(self, size, a, b, flags=None): """ ``mult`` multiplies expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -700,9 +700,9 @@ class LowLevelILFunction(object): :return: The expression ``sbc.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MUL, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MUL, a.index, b.index, size=size, flags=flags) - def mult_double_prec_signed(self, size, a, b, flags = None): + def mult_double_prec_signed(self, size, a, b, flags=None): """ ``mult_double_prec_signed`` multiplies signed with double precision expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -714,9 +714,9 @@ class LowLevelILFunction(object): :return: The expression ``muls.dp.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MULS_DP, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MULS_DP, a.index, b.index, size=size, flags=flags) - def mult_double_prec_unsigned(self, size, a, b, flags = None): + def mult_double_prec_unsigned(self, size, a, b, flags=None): """ ``mult_double_prec_unsigned`` multiplies unsigned with double precision expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -728,9 +728,9 @@ class LowLevelILFunction(object): :return: The expression ``muls.dp.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MULU_DP, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MULU_DP, a.index, b.index, size=size, flags=flags) - def div_signed(self, size, a, b, flags = None): + def div_signed(self, size, a, b, flags=None): """ ``div_signed`` signed divide expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -742,9 +742,9 @@ class LowLevelILFunction(object): :return: The expression ``divs.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_DIVS, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_DIVS, a.index, b.index, size=size, flags=flags) - def div_double_prec_signed(self, size, hi, lo, b, flags = None): + def div_double_prec_signed(self, size, hi, lo, b, flags=None): """ ``div_double_prec_signed`` signed double precision divide using expression ``hi`` and expression ``lo`` as a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an @@ -758,9 +758,9 @@ class LowLevelILFunction(object): :return: The expression ``divs.dp.{}(hi:lo, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_DIVS_DP, hi.index, lo.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_DIVS_DP, hi.index, lo.index, b.index, size=size, flags=flags) - def div_unsigned(self, size, a, b, flags = None): + def div_unsigned(self, size, a, b, flags=None): """ ``div_unsigned`` unsigned divide expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -772,9 +772,9 @@ class LowLevelILFunction(object): :return: The expression ``divs.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_DIVS, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_DIVS, a.index, b.index, size=size, flags=flags) - def div_double_prec_unsigned(self, size, hi, lo, b, flags = None): + def div_double_prec_unsigned(self, size, hi, lo, b, flags=None): """ ``div_double_prec_unsigned`` unsigned double precision divide using expression ``hi`` and expression ``lo`` as a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an @@ -788,9 +788,9 @@ class LowLevelILFunction(object): :return: The expression ``divs.dp.{}(hi:lo, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_DIVS_DP, hi.index, lo.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_DIVS_DP, hi.index, lo.index, b.index, size=size, flags=flags) - def mod_signed(self, size, a, b, flags = None): + def mod_signed(self, size, a, b, flags=None): """ ``mod_signed`` signed modulus expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -802,9 +802,9 @@ class LowLevelILFunction(object): :return: The expression ``mods.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MODS, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MODS, a.index, b.index, size=size, flags=flags) - def mod_double_prec_signed(self, size, hi, lo, b, flags = None): + def mod_double_prec_signed(self, size, hi, lo, b, flags=None): """ ``mod_double_prec_signed`` signed double precision modulus using expression ``hi`` and expression ``lo`` as a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an expression @@ -818,9 +818,9 @@ class LowLevelILFunction(object): :return: The expression ``mods.dp.{}(hi:lo, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MODS_DP, hi.index, lo.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MODS_DP, hi.index, lo.index, b.index, size=size, flags=flags) - def mod_unsigned(self, size, a, b, flags = None): + def mod_unsigned(self, size, a, b, flags=None): """ ``mod_unsigned`` unsigned modulus expression ``a`` by expression ``b`` potentially setting flags ``flags`` and returning an expression of ``size`` bytes. @@ -832,9 +832,9 @@ class LowLevelILFunction(object): :return: The expression ``modu.{}(a, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MODS, a.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MODS, a.index, b.index, size=size, flags=flags) - def mod_double_prec_unsigned(self, size, hi, lo, b, flags = None): + def mod_double_prec_unsigned(self, size, hi, lo, b, flags=None): """ ``mod_double_prec_unsigned`` unsigned double precision modulus using expression ``hi`` and expression ``lo`` as a single double precision register by expression ``b`` potentially setting flags ``flags`` and returning an @@ -848,9 +848,9 @@ class LowLevelILFunction(object): :return: The expression ``modu.dp.{}(hi:lo, b)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_MODS_DP, hi.index, lo.index, b.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_MODS_DP, hi.index, lo.index, b.index, size=size, flags=flags) - def neg_expr(self, size, value, flags = None): + def neg_expr(self, size, value, flags=None): """ ``neg_expr`` two's complement sign negation of expression ``value`` of size ``size`` potentially setting flags @@ -860,9 +860,9 @@ class LowLevelILFunction(object): :return: The expression ``neg.{}(value)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_NEG, value.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_NEG, value.index, size=size, flags=flags) - def not_expr(self, size, value, flags = None): + def not_expr(self, size, value, flags=None): """ ``not_expr`` bitwise inverse of expression ``value`` of size ``size`` potentially setting flags @@ -872,29 +872,30 @@ class LowLevelILFunction(object): :return: The expression ``not.{}(value)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_NOT, value.index, size = size, flags = flags) + return self.expr(core.BNLowLevelILOperation.LLIL_NOT, value.index, size=size, flags=flags) - def sign_extend(self, size, value): + def sign_extend(self, size, value, flags=None): """ ``sign_extend`` two's complement sign-extends the expression in ``value`` to ``size`` bytes :param int size: the size of the result in bytes - :param LowLevelILExpr value: the expression to sign extend + :param LowLevelILExpr value: the expression to sign extn + :param str flags: optional, flags to set :return: The expression ``sx.(value)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_SX, value.index, size = size) + return self.expr(core.BNLowLevelILOperation.LLIL_SX, value.index, size=size, flags=flags) def zero_extend(self, size, value): """ - ``sign_extend`` zero-extends the expression in ``value`` to ``size`` bytes + ``zero_extend`` zero-extends the expression in ``value`` to ``size`` bytes :param int size: the size of the result in bytes :param LowLevelILExpr value: the expression to zero extend :return: The expression ``sx.(value)`` :rtype: LowLevelILExpr """ - return self.expr(core.BNLowLevelILOperation.LLIL_ZX, value.index, size = size) + return self.expr(core.BNLowLevelILOperation.LLIL_ZX, value.index, size=size) def jump(self, dest): """ -- cgit v1.3.1