diff options
Diffstat (limited to '')
52 files changed, 199 insertions, 199 deletions
diff --git a/miasm2/analysis/binary.py b/miasm2/analysis/binary.py index 6dfef92a..90d71369 100644 --- a/miasm2/analysis/binary.py +++ b/miasm2/analysis/binary.py @@ -36,7 +36,7 @@ class Container(object): @classmethod def from_string(cls, data, *args, **kwargs): - """Instanciate a container and parse the binary + """Instantiate a container and parse the binary @data: str containing the binary """ log.info('Load binary') @@ -65,7 +65,7 @@ class Container(object): @classmethod def from_stream(cls, stream, *args, **kwargs): - """Instanciate a container and parse the binary + """Instantiate a container and parse the binary @stream: stream to use as binary @vm: (optional) VmMngr instance to link with the executable @addr: (optional) Shift to apply before parsing the binary. If set, diff --git a/miasm2/analysis/cst_propag.py b/miasm2/analysis/cst_propag.py index 43e83c4a..9a5e3d54 100644 --- a/miasm2/analysis/cst_propag.py +++ b/miasm2/analysis/cst_propag.py @@ -26,8 +26,8 @@ def add_state(ircfg, todo, states, addr, state): """ Add or merge the computed @state for the block at @addr. Update @todo @todo: modified block set - @states: dictionnary linking a label to its entering state. - @addr: address of the concidered block + @states: dictionary linking a label to its entering state. + @addr: address of the considered block @state: computed state """ addr = ircfg.get_loc_key(addr) @@ -122,7 +122,7 @@ def compute_cst_propagation_states(ir_arch, ircfg, init_addr, init_infos): @ir_arch: IntermediateRepresentation instance @init_addr: analysis start address - @init_infos: dictionnary linking expressions to their values at @init_addr + @init_infos: dictionary linking expressions to their values at @init_addr """ done = set() @@ -169,7 +169,7 @@ def propagate_cst_expr(ir_arch, ircfg, addr, init_infos): @ir_arch: IntermediateRepresentation instance @addr: analysis start address - @init_infos: dictionnary linking expressions to their values at @init_addr + @init_infos: dictionary linking expressions to their values at @init_addr Returns a mapping between replaced Expression and their new values. """ diff --git a/miasm2/analysis/data_flow.py b/miasm2/analysis/data_flow.py index 49519e9c..23e2f77e 100644 --- a/miasm2/analysis/data_flow.py +++ b/miasm2/analysis/data_flow.py @@ -28,7 +28,7 @@ class ReachingDefinitions(dict): A survey of data flow analysis techniques. IBM Thomas J. Watson Research Division, Algorithm MK - This class is usable as a dictionnary whose struture is + This class is usable as a dictionary whose structure is { (block, index): { lvalue: set((block, index)) } } """ @@ -122,7 +122,7 @@ class DiGraphDefUse(DiGraph): def __init__(self, reaching_defs, deref_mem=False, *args, **kwargs): - """Instanciate a DiGraph + """Instantiate a DiGraph @blocks: IR blocks """ self._edge_attr = {} @@ -171,7 +171,7 @@ class DiGraphDefUse(DiGraph): def add_uniq_labeled_edge(self, src, dst, edge_label): """Adds the edge (@src, @dst) with label @edge_label. - if edge (@src, @dst) already exists, the previous label is overriden + if edge (@src, @dst) already exists, the previous label is overridden """ self.add_uniq_edge(src, dst) self._edge_attr[(src, dst)] = edge_label @@ -216,7 +216,7 @@ def dead_simp_useful_assignblks(irarch, defuse, reaching_defs): else: keep_all_definitions = False - # Block has a nonexistant successor or is a leaf + # Block has a nonexistent successor or is a leaf if keep_all_definitions or (len(successors) == 0): valid_definitions = reaching_defs.get_definitions(block_lbl, len(block)) @@ -831,7 +831,7 @@ def check_expr_below_stack(ir_arch_a, expr): def retrieve_stack_accesses(ir_arch_a, ssa): """ Walk the ssa graph and find stack based variables. - Return a dictionnary linking stack base address to its size/name + Return a dictionary linking stack base address to its size/name @ir_arch_a: ira instance @ssa: SSADiGraph instance """ @@ -881,9 +881,9 @@ def retrieve_stack_accesses(ir_arch_a, ssa): def fix_stack_vars(expr, base_to_info): """ - Replace local stack accesses in expr using informations in @base_to_info + Replace local stack accesses in expr using information in @base_to_info @expr: Expression instance - @base_to_info: dictionnary linking stack base address to its size/name + @base_to_info: dictionary linking stack base address to its size/name """ if not expr.is_mem(): return expr diff --git a/miasm2/analysis/depgraph.py b/miasm2/analysis/depgraph.py index 5923e7ed..62967991 100644 --- a/miasm2/analysis/depgraph.py +++ b/miasm2/analysis/depgraph.py @@ -279,7 +279,7 @@ class DependencyResult(DependencyState): """Symbolic execution of relevant nodes according to the history Return the values of inputs nodes' elements @ir_arch: IntermediateRepresentation instance - @ctx: (optional) Initial context as dictionnary + @ctx: (optional) Initial context as dictionary @step: (optional) Verbose execution Warning: The emulation is not sound if the inputs nodes depend on loop variant. @@ -447,7 +447,7 @@ class DependencyGraph(object): A dependency graph contains DependencyNode as nodes. The oriented edges stand for a dependency. The dependency graph is made of the lines of a group of IRblock - *explicitely* or *implicitely* involved in the equation of given element. + *explicitly* or *implicitly* involved in the equation of given element. """ def __init__(self, ircfg, diff --git a/miasm2/analysis/dse.py b/miasm2/analysis/dse.py index 1875f138..3a986537 100644 --- a/miasm2/analysis/dse.py +++ b/miasm2/analysis/dse.py @@ -35,7 +35,7 @@ If one is only interested in constraints associated to its path, the option The constraints are accumulated in the .z3_cur z3.Solver object. Here are a few remainings TODO: - - handle endianess in check_state / atomic read: currently, but this is also + - handle endianness in check_state / atomic read: currently, but this is also true for others Miasm2 symbolic engines, the endianness is not take in account, and assumed to be Little Endian @@ -143,7 +143,7 @@ class ESETrackModif(EmulatedSymbExec): class DSEEngine(object): """Dynamic Symbolic Execution Engine - This class aims to be overrided for each specific purpose + This class aims to be overridden for each specific purpose """ SYMB_ENGINE = ESETrackModif @@ -208,7 +208,7 @@ class DSEEngine(object): dse.attach(jitter) dse.update... ... - # Additionnal call to the exec callback is necessary, as breakpoints are + # Additional call to the exec callback is necessary, as breakpoints are # honored AFTER exec callback jitter.exec_cb(jitter) diff --git a/miasm2/analysis/machine.py b/miasm2/analysis/machine.py index 7b24328a..f12b7e57 100644 --- a/miasm2/analysis/machine.py +++ b/miasm2/analysis/machine.py @@ -2,7 +2,7 @@ class Machine(object): - """Abstract machine architecture to restrict architecture dependant code""" + """Abstract machine architecture to restrict architecture dependent code""" __dis_engine = None # Disassembly engine __mn = None # Machine instance diff --git a/miasm2/analysis/modularintervals.py b/miasm2/analysis/modularintervals.py index 650dbc21..83890f19 100644 --- a/miasm2/analysis/modularintervals.py +++ b/miasm2/analysis/modularintervals.py @@ -7,7 +7,7 @@ class ModularIntervals(object): """Intervals with a maximum size, supporting modular arithmetic""" def __init__(self, size, intervals=None): - """Instanciate a ModularIntervals of size @size + """Instantiate a ModularIntervals of size @size @size: maximum size of elements @intervals: (optional) interval instance, or any type supported by interval initialisation; element of the current instance diff --git a/miasm2/analysis/ssa.py b/miasm2/analysis/ssa.py index 0320d117..c22aae59 100644 --- a/miasm2/analysis/ssa.py +++ b/miasm2/analysis/ssa.py @@ -579,7 +579,7 @@ class SSADiGraph(SSA): def get_assignblk(graph, loc, index): """ - Return the dictionnary of the AssignBlock from @graph at location @loc at + Return the dictionary of the AssignBlock from @graph at location @loc at @index @graph: IRCFG instance @loc: Location instance @@ -595,13 +595,13 @@ def get_assignblk(graph, loc, index): def set_assignblk(graph, loc, index, assignblk_dct): """ - Set the Assignblock in @graph at location @loc at @index using dictionnary + Set the Assignblock in @graph at location @loc at @index using dictionary @assignblk_dct @graph: IRCFG instance @loc: Location instance @index: assignblock index - @assignblk_dct: dictionnary representing the AssignBlock + @assignblk_dct: dictionary representing the AssignBlock """ irblock = graph.blocks[loc] @@ -629,7 +629,7 @@ def remove_phi(ssa, head): all_ssa_vars = ssa._ssa_variable_to_expr - # Retrive Phi nodes + # Retrieve Phi nodes phi_nodes = [] for irblock in ssa.graph.blocks.itervalues(): for index, assignblk in enumerate(irblock): diff --git a/miasm2/arch/aarch64/arch.py b/miasm2/arch/aarch64/arch.py index 598aca83..38cffc47 100644 --- a/miasm2/arch/aarch64/arch.py +++ b/miasm2/arch/aarch64/arch.py @@ -444,7 +444,7 @@ class mn_aarch64(cls_mn): return 0 o = 0 if n > bs.getlen() * 8: - raise ValueError('not enought bits %r %r' % (n, len(bs.bin) * 8)) + raise ValueError('not enough bits %r %r' % (n, len(bs.bin) * 8)) while n: offset = start / 8 n_offset = cls.endian_offset(attrib, offset) @@ -1068,7 +1068,7 @@ class bits(object): __slots__ = ["size", "value"] def __init__(self, size, value): - """Instanciate a bitvector of size @size with value @value""" + """Instantiate a bitvector of size @size with value @value""" self.size = size if value & self.mask != value: raise ValueError("Value %s is too large for %d bits", @@ -2065,7 +2065,7 @@ aarch64op("fmsub", [bs('0'), bs('00'), bs('11111'), bs('0'), sdsize1, bs('0'), s aarch64op("fnmadd",[bs('0'), bs('00'), bs('11111'), bs('0'), sdsize1, bs('1'), sdm_32_64, bs('0'), sda_32_64, sdn_32_64, sdd_32_64], [sdd_32_64, sdn_32_64, sdm_32_64, sda_32_64]) aarch64op("fnmsub",[bs('0'), bs('00'), bs('11111'), bs('0'), sdsize1, bs('1'), sdm_32_64, bs('1'), sda_32_64, sdn_32_64, sdd_32_64], [sdd_32_64, sdn_32_64, sdm_32_64, sda_32_64]) -# convertion float integer p.235 +# conversion float integer p.235 aarch64op("scvtf", [sf, bs('0'), bs('0'), bs('11110'), bs('0'), sdsize1, bs('1'), bs('00'), bs('010'), bs('000000'), rn, sdd_32_64], [sdd_32_64, rn]) aarch64op("ucvtf", [sf, bs('0'), bs('0'), bs('11110'), bs('0'), sdsize1, bs('1'), bs('00'), bs('011'), bs('000000'), rn, sdd_32_64], [sdd_32_64, rn]) diff --git a/miasm2/arch/arm/arch.py b/miasm2/arch/arm/arch.py index 5fbaa946..d4b7d05a 100644 --- a/miasm2/arch/arm/arch.py +++ b/miasm2/arch/arm/arch.py @@ -608,7 +608,7 @@ class mn_arm(cls_mn): return 0 o = 0 if n > bs.getlen() * 8: - raise ValueError('not enought bits %r %r' % (n, len(bs.bin) * 8)) + raise ValueError('not enough bits %r %r' % (n, len(bs.bin) * 8)) while n: offset = start / 8 n_offset = cls.endian_offset(attrib, offset) @@ -709,7 +709,7 @@ class mn_armt(cls_mn): return 0 o = 0 if n > bs.getlen() * 8: - raise ValueError('not enought bits %r %r' % (n, len(bs.bin) * 8)) + raise ValueError('not enough bits %r %r' % (n, len(bs.bin) * 8)) while n: offset = start / 8 n_offset = cls.endian_offset(attrib, offset) diff --git a/miasm2/arch/arm/sem.py b/miasm2/arch/arm/sem.py index ac1d9ce9..4af177d2 100644 --- a/miasm2/arch/arm/sem.py +++ b/miasm2/arch/arm/sem.py @@ -778,7 +778,7 @@ def st_ld_r(ir, instr, a, a2, b, store=False, size=32, s_ext=False, z_ext=False) else: ad = base + off - # PC base lookup uses PC 4 byte alignemnt + # PC base lookup uses PC 4 byte alignment ad = ad.replace_expr({PC: PC & ExprInt(0xFFFFFFFC, 32)}) dmem = False @@ -1700,7 +1700,7 @@ class ir_arml(IntermediateRepresentation): cond_eq = tab_cond[cond_num] if not index + len(it_hints) <= len(block.lines): - raise NotImplementedError("Splitted IT block non supported yet") + raise NotImplementedError("Split IT block non supported yet") ir_blocks_all = [] diff --git a/miasm2/arch/mep/arch.py b/miasm2/arch/mep/arch.py index 3cfa55a6..e4d66a63 100644 --- a/miasm2/arch/mep/arch.py +++ b/miasm2/arch/mep/arch.py @@ -313,7 +313,7 @@ class mn_mep(cls_mn): all_mn_inst = defaultdict(list) # mnemonics objects # Note: # - the key is the mnemonic Python class - # - the data is an instanciated object + # - the data is an instantiated object bintree = dict() # Variable storing internal values used to guess a # mnemonic during disassembly @@ -321,7 +321,7 @@ class mn_mep(cls_mn): # Defines the instruction set that will be used instruction = instruction_mep - # Python module that stores registers informations + # Python module that stores registers information regs = mep_regs_module # Default delay slot @@ -826,7 +826,7 @@ class mep_copro_reg_split(mep_copro_reg): class mep_deref_inc_reg(mep_deref_reg): - """Generic Toshiba MeP-c4 coprocess dereferenced & incremented registe + """Generic Toshiba MeP-c4 coprocess dereferenced & incremented register """ parser = deref_inc_reg_parser diff --git a/miasm2/arch/mep/sem.py b/miasm2/arch/mep/sem.py index 9e0cba6b..fb67becd 100644 --- a/miasm2/arch/mep/sem.py +++ b/miasm2/arch/mep/sem.py @@ -265,18 +265,18 @@ def advck3(r0, rn, rm): @sbuild.parse def sub(reg1, reg2): - """SUB - Substract one register to another.""" + """SUB - Subtract one register to another.""" # Rn <- Rn - Rm reg1 = reg1 - reg2 def sbvck3(ir, instr, r0, rn, rm): - """SBVCK3 - Check substraction overflow""" + """SBVCK3 - Check subtraction overflow""" # if(Overflow(Rn-Rm)) R0<-1 else R0<-0 (Signed) - # Substract registers + # Subtract registers reg_sub = ExprOp("+", rn, rm) # Get the register storing the highest value @@ -1160,7 +1160,7 @@ class ir_mepb(IntermediateRepresentation): return instr_ir, extra_ir def get_next_break_loc_key(self, instr): - """Returns a new label that identifies where the instuction is going. + """Returns a new label that identifies where the instruction is going. Note: it eases linking IR blocs """ diff --git a/miasm2/arch/msp430/arch.py b/miasm2/arch/msp430/arch.py index a8f75f39..f0db98f3 100644 --- a/miasm2/arch/msp430/arch.py +++ b/miasm2/arch/msp430/arch.py @@ -236,7 +236,7 @@ class mn_msp430(cls_mn): return 0 o = 0 if n > bs.getlen() * 8: - raise ValueError('not enought bits %r %r' % (n, len(bs.bin) * 8)) + raise ValueError('not enough bits %r %r' % (n, len(bs.bin) * 8)) while n: i = start / 8 c = cls.getbytes(bs, i) diff --git a/miasm2/arch/msp430/ctype.py b/miasm2/arch/msp430/ctype.py index adb0a953..464adaf8 100644 --- a/miasm2/arch/msp430/ctype.py +++ b/miasm2/arch/msp430/ctype.py @@ -3,7 +3,7 @@ from miasm2.core.ctypesmngr import CTypeId, CTypePtr class CTypeMSP430_unk(CLeafTypes): - """Define C types sizes/alignement for msp430 architecture""" + """Define C types sizes/alignment for msp430 architecture""" obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1 diff --git a/miasm2/arch/sh4/arch.py b/miasm2/arch/sh4/arch.py index c6dea0d6..88d734a3 100644 --- a/miasm2/arch/sh4/arch.py +++ b/miasm2/arch/sh4/arch.py @@ -508,7 +508,7 @@ class mn_sh4(cls_mn): return 0 o = 0 if n > bs.getlen() * 8: - raise ValueError('not enought bits %r %r' % (n, len(bs.bin) * 8)) + raise ValueError('not enough bits %r %r' % (n, len(bs.bin) * 8)) while n: i = start / 8 c = cls.getbytes(bs, i) diff --git a/miasm2/arch/x86/arch.py b/miasm2/arch/x86/arch.py index feafcd44..77744ccd 100644 --- a/miasm2/arch/x86/arch.py +++ b/miasm2/arch/x86/arch.py @@ -275,7 +275,7 @@ class x86_arg(m_arg): loc_key = loc_db.get_or_create_name_location(value.name) return ExprLoc(loc_key, size_hint) if isinstance(value, AstOp): - # First pass to retreive fixed_size + # First pass to retrieve fixed_size if value.op == "segm": segm = self.asm_ast_to_expr(value.args[0], loc_db) ptr = self.asm_ast_to_expr(value.args[1], loc_db, None, fixed_size) @@ -930,7 +930,7 @@ class bs_modname_size(bs_divert): (dct['mode'], dct['opmode'], dct['admode'])) mode = dct['mode'] size, opmode, admode = dct['mode'], dct['opmode'], dct['admode'] - # no mode64 existance in name means no 64bit version of mnemo + # no mode64 exinstance in name means no 64bit version of mnemo if mode == 64: if mode in self.args['name']: nfields = fields[:] diff --git a/miasm2/arch/x86/ctype.py b/miasm2/arch/x86/ctype.py index 5e16f945..5d1be0de 100644 --- a/miasm2/arch/x86/ctype.py +++ b/miasm2/arch/x86/ctype.py @@ -3,7 +3,7 @@ from miasm2.core.ctypesmngr import CTypeId, CTypePtr class CTypeAMD64_unk(CLeafTypes): - """Define C types sizes/alignement for x86_64 architecture""" + """Define C types sizes/alignment for x86_64 architecture""" obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1 @@ -72,7 +72,7 @@ class CTypeAMD64_unk(CLeafTypes): class CTypeX86_unk(CLeafTypes): - """Define C types sizes/alignement for x86_32 architecture""" + """Define C types sizes/alignment for x86_32 architecture""" obj_pad = ObjCDecl(PADDING_TYPE_NAME, 1, 1) # __padding__ is size 1/align 1 diff --git a/miasm2/arch/x86/sem.py b/miasm2/arch/x86/sem.py index b8317ea7..244aff30 100644 --- a/miasm2/arch/x86/sem.py +++ b/miasm2/arch/x86/sem.py @@ -314,8 +314,8 @@ def fix_mem_args_size(instr, *args): def mem2double(instr, arg): """ - Add float convertion if argument is an ExprMem - @arg: argument to tranform + Add float conversion if argument is an ExprMem + @arg: argument to transform """ if isinstance(arg, m2_expr.ExprMem): if arg.size > 64: @@ -341,8 +341,8 @@ def gen_jcc(ir, instr, cond, dst, jmp_if): Macro to generate jcc semantic @ir: ir instance @instr: instruction - @cond: condtion of the jcc - @dst: the dstination if jcc is taken + @cond: condition of the jcc + @dst: the destination if jcc is taken @jmp_if: jump if/notif cond """ @@ -733,7 +733,7 @@ def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False, isize = m2_expr.ExprInt(a.size, size=a.size) mask = m2_expr.ExprOp(op_inv, i1, (isize - shifter)) - i1 - # An overflow can occured, emulate the 'undefined behavior' + # An overflow can occurred, emulate the 'undefined behavior' # Overflow behavior if (shift / size % 2) base_cond_overflow = shifter if left else ( shifter - m2_expr.ExprInt(1, size=shifter.size)) @@ -755,7 +755,7 @@ def _shift_tpl(op, ir, instr, a, b, c=None, op_inv=None, left=False, cf_from_src = cf_from_src.msb() if left else cf_from_src[:1] new_cf = m2_expr.ExprCond(cond_overflow, cf_from_src, cf_from_dst) - # Overflow flag, only occured when shifter is equal to 1 + # Overflow flag, only occurred when shifter is equal to 1 if custom_of is None: value_of = a.msb() ^ a[-2:-1] if left else b[:1] ^ a.msb() else: @@ -3641,12 +3641,12 @@ def movd(_, instr, dst, src): def movdqu(_, instr, dst, src): - # XXX TODO alignement check + # XXX TODO alignment check return [m2_expr.ExprAssign(dst, src)], [] def movapd(_, instr, dst, src): - # XXX TODO alignement check + # XXX TODO alignment check return [m2_expr.ExprAssign(dst, src)], [] @@ -3899,7 +3899,7 @@ def _average(expr): arg1 = expr.args[0].zeroExtend(expr.size * 2) arg2 = expr.args[1].zeroExtend(expr.size * 2) one = m2_expr.ExprInt(1, arg1.size) - # avg(unsigned) = (a + b + 1) >> 1, addition beeing at least on one more bit + # avg(unsigned) = (a + b + 1) >> 1, addition being at least on one more bit return ((arg1 + arg2 + one) >> one)[:expr.size] pavgb = vec_vertical_instr('avg', 8, _average) @@ -4843,7 +4843,7 @@ def _saturation_sub_unsigned(expr): def _saturation_sub_signed(expr): assert expr.is_op("+") and len(expr.args) == 2 and expr.args[-1].is_op("-") - # Compute the substraction on two more bits, see _saturation_sub_unsigned + # Compute the subtraction on two more bits, see _saturation_sub_unsigned arg1 = expr.args[0].signExtend(expr.size + 2) arg2 = expr.args[1].args[0].signExtend(expr.size + 2) return _signed_saturation(arg1 - arg2, expr.size) @@ -4857,7 +4857,7 @@ def _saturation_add(expr): arg1 = expr.args[0].zeroExtend(expr.size + 1) arg2 = expr.args[1].zeroExtend(expr.size + 1) - # We can also use _unsigned_saturation with two additionnal bits (to + # We can also use _unsigned_saturation with two additional bits (to # distinguish minus and overflow case) # The resulting expression being more complicated with an impossible case # (signed=True), we rewrite the rule here @@ -4868,7 +4868,7 @@ def _saturation_add(expr): def _saturation_add_signed(expr): assert expr.is_op("+") and len(expr.args) == 2 - # Compute the substraction on two more bits, see _saturation_add_unsigned + # Compute the subtraction on two more bits, see _saturation_add_unsigned arg1 = expr.args[0].signExtend(expr.size + 2) arg2 = expr.args[1].signExtend(expr.size + 2) @@ -5306,10 +5306,10 @@ mnemo_func = {'mov': mov, "movd": movd, "movdqu": movdqu, "movdqa": movdqu, - "movapd": movapd, # XXX TODO alignement check - "movupd": movapd, # XXX TODO alignement check - "movaps": movapd, # XXX TODO alignement check - "movups": movapd, # XXX TODO alignement check + "movapd": movapd, # XXX TODO alignment check + "movupd": movapd, # XXX TODO alignment check + "movaps": movapd, # XXX TODO alignment check + "movups": movapd, # XXX TODO alignment check "andps": andps, "andpd": andps, "andnps": andnps, @@ -5600,7 +5600,7 @@ class ir_x86_16(IntermediateRepresentation): self.IRDst = m2_expr.ExprId('IRDst', 16) # Size of memory pointer access in IR # 16 bit mode memory accesses may be greater than 16 bits - # 32 bit size may be enought + # 32 bit size may be enough self.addrsize = 32 def mod_pc(self, instr, instr_ir, extra_ir): diff --git a/miasm2/core/asmblock.py b/miasm2/core/asmblock.py index 34f11474..f6e68a0e 100644 --- a/miasm2/core/asmblock.py +++ b/miasm2/core/asmblock.py @@ -313,8 +313,8 @@ class AsmBlockBad(AsmBlock): } def __init__(self, loc_key=None, alignment=1, errno=ERROR_UNKNOWN, *args, **kwargs): - """Instanciate an AsmBlock_bad. - @loc_key, @alignement: same as AsmBlock.__init__ + """Instantiate an AsmBlock_bad. + @loc_key, @alignment: same as AsmBlock.__init__ @errno: (optional) specify a error type associated with the block """ super(AsmBlockBad, self).__init__(loc_key, alignment, *args, **kwargs) @@ -334,7 +334,7 @@ class AsmBlockBad(AsmBlock): raise RuntimeError("An AsmBlockBad cannot have bto") def split(self, *args, **kwargs): - raise RuntimeError("An AsmBlockBad cannot be splitted") + raise RuntimeError("An AsmBlockBad cannot be split") class asm_block_bad(AsmBlockBad): @@ -486,7 +486,7 @@ class AsmCFG(DiGraph): Edges will be created for @block.bto, if destinations are already in this instance. If not, they will be resolved when adding these - aforementionned destinations. + aforementioned destinations. `self.pendings` indicates which blocks are not yet resolved. """ @@ -795,7 +795,7 @@ class AsmCFG(DiGraph): if not (off > range_start and off < range_stop): continue - # `cur_block` must be splitted at offset `off`from miasm2.core.locationdb import LocationDB + # `cur_block` must be split at offset `off`from miasm2.core.locationdb import LocationDB new_b = cur_block.split(loc_db, off) log_asmblock.debug("Split block %x", off) @@ -1253,7 +1253,7 @@ def asmblock_final(mnemo, asmcfg, blockChains, loc_db, conservative=False): chain.fix_blocks(modified_loc_keys) for loc_key in modified_loc_keys: - # Retrive block with modified reference + # Retrieve block with modified reference mod_block = asmcfg.loc_key_to_block(loc_key) if mod_block is not None: blocks_to_rework.add(mod_block) @@ -1343,7 +1343,7 @@ class disasmEngine(object): """ def __init__(self, arch, attrib, bin_stream, **kwargs): - """Instanciate a new disassembly engine + """Instantiate a new disassembly engine @arch: targeted architecture @attrib: architecture attribute @bin_stream: bytes source diff --git a/miasm2/core/cpu.py b/miasm2/core/cpu.py index 813ac47d..c2fbd3cd 100644 --- a/miasm2/core/cpu.py +++ b/miasm2/core/cpu.py @@ -44,7 +44,7 @@ class bitobj: if not n: return 0 if n > len(self.bits) - self.offset: - raise ValueError('not enought bits %r %r' % (n, len(self.bits))) + raise ValueError('not enough bits %r %r' % (n, len(self.bits))) b = self.bits[self.offset:self.offset + n] b = int("".join([str(x) for x in b]), 2) self.offset += n @@ -1063,7 +1063,7 @@ class cls_mn(object): __metaclass__ = metamn args_symb = [] instruction = instruction - # Block's offset alignement + # Block's offset alignment alignment = 1 @classmethod diff --git a/miasm2/core/ctypesmngr.py b/miasm2/core/ctypesmngr.py index 5daf8950..7dafd7e1 100644 --- a/miasm2/core/ctypesmngr.py +++ b/miasm2/core/ctypesmngr.py @@ -61,7 +61,7 @@ class CTypeId(CTypeBase): def __init__(self, *names): # Type specifier order does not matter - # so the cannonical form is ordered + # so the canonical form is ordered self.names = tuple(sorted(names)) super(CTypeId, self).__init__() @@ -372,7 +372,7 @@ class CAstTypes(object): } def gen_uniq_name(self): - """Generate uniq name for unamed strucs/union""" + """Generate uniq name for unnamed strucs/union""" cpt = self.cpt self.cpt += 1 return self.INTERNAL_PREFIX + "%d" % cpt @@ -554,7 +554,7 @@ class CAstTypes(object): elif isinstance(ast, c_ast.Constant): result = int(ast.value, 0) elif isinstance(ast, c_ast.Cast): - # TODO: Can trunc intergers? + # TODO: Can trunc integers? result = self.ast_eval_int(ast.expr) else: raise NotImplementedError("Not implemented!") diff --git a/miasm2/core/graph.py b/miasm2/core/graph.py index 35bcf01d..f61d1e67 100644 --- a/miasm2/core/graph.py +++ b/miasm2/core/graph.py @@ -301,8 +301,8 @@ class DiGraph(object): of the graph. @head: the head/leaf of the graph @reachable_cb: sons/parents of the head/leaf - @prev_cb: return predecessors/succesors of a node - @next_cb: return succesors/predecessors of a node + @prev_cb: return predecessors/successors of a node + @next_cb: return successors/predecessors of a node """ nodes = set(reachable_cb(head)) @@ -382,7 +382,7 @@ class DiGraph(object): @node: The start node @gen_dominators: The dictionary containing at least node's dominators/post_dominators - @succ_cb: return predecessors/succesors of a node + @succ_cb: return predecessors/successors of a node """ # Init @@ -756,7 +756,7 @@ class MatchGraphJoker(object): def __init__(self, restrict_in=True, restrict_out=True, filt=None, name=None): - """Instanciate a MatchGraphJoker, with restrictions + """Instantiate a MatchGraphJoker, with restrictions @restrict_in: (optional) if set, the number of predecessors of the matched node must be the same than the joker node in the associated MatchGraph @@ -809,7 +809,7 @@ class MatchGraph(DiGraph): restrictions. The implemented algorithm is a naive approach. - The recommended way to instanciate a MatchGraph is the use of + The recommended way to instantiate a MatchGraph is the use of MatchGraphJoker. """ @@ -937,7 +937,7 @@ class MatchGraph(DiGraph): # Partial solution: nodes corrects, edges between these nodes corrects # A partial solution is a dictionary MatchGraphJoker -> @graph's node todo = list() # Dictionnaries containing partial solution - done = list() # Aleady computed partial solutions + done = list() # Already computed partial solutions # Elect first candidates to_match = next(iter(self._nodes)) diff --git a/miasm2/core/locationdb.py b/miasm2/core/locationdb.py index 7d84c491..b6e60794 100644 --- a/miasm2/core/locationdb.py +++ b/miasm2/core/locationdb.py @@ -13,7 +13,7 @@ class LocationDB(object): LocationDB is a "database" of information associated to location. An entry in a LocationDB is uniquely identified with a LocKey. - Additionnal information which can be associated with a LocKey are: + Additional information which can be associated with a LocKey are: - an offset (uniq per LocationDB) - several names (each are uniqs per LocationDB) @@ -22,7 +22,7 @@ class LocationDB(object): 1 <-> 0..n name >>> loc_db = LocationDB() - # Add a location with no additionnal information + # Add a location with no additional information >>> loc_key1 = loc_db.add_location() # Add a location with an offset >>> loc_key2 = loc_db.add_location(offset=0x1234) @@ -221,7 +221,7 @@ class LocationDB(object): if is_int(name): assert offset is None or offset == name warnings.warn("Deprecated API: use 'add_location(offset=)' instead." - " An additionnal 'name=' can be provided to also " + " An additional 'name=' can be provided to also " "associate a name (there is no more default name)") offset = name name = None diff --git a/miasm2/core/objc.py b/miasm2/core/objc.py index 0e5e8cf4..64a935a7 100644 --- a/miasm2/core/objc.py +++ b/miasm2/core/objc.py @@ -716,7 +716,7 @@ def ast_get_c_access_expr(ast, expr_types, lvl=0): """Transform C ast object into a C Miasm expression @ast: parsed pycparser.c_ast object - @expr_types: a dictionnary linking ID names to their types + @expr_types: a dictionary linking ID names to their types @lvl: actual recursion level Example: @@ -796,7 +796,7 @@ class ExprToAccessC(ExprReducer): def __init__(self, expr_types, types_mngr, enforce_strict_access=True): """Init GenCAccess - @expr_types: a dictionnary linking ID names to their types + @expr_types: a dictionary linking ID names to their types @types_mngr: types manager @enforce_strict_access: If false, generate access even on expression pointing to a middle of an object. If true, raise exception if such a @@ -809,7 +809,7 @@ class ExprToAccessC(ExprReducer): def updt_expr_types(self, expr_types): """Update expr_types - @expr_types: Dictionnary associating name to type + @expr_types: Dictionary associating name to type """ self.expr_types = expr_types @@ -969,7 +969,7 @@ class ExprToAccessC(ExprReducer): def get_solo_type(self, node): """Return the type of the @node if it has only one possible type, - different from not None. In othe cases, return None. + different from not None. In other cases, return None. """ if node.info is None or len(node.info) != 1: return None @@ -1060,7 +1060,7 @@ class ExprToAccessC(ExprReducer): def get_accesses(self, expr, expr_context=None): """Generate C access(es) for the native Miasm expression @expr @expr: native Miasm expression - @expr_context: a dictionnary linking known expressions to their + @expr_context: a dictionary linking known expressions to their types. An expression is linked to a tuple of types. """ if expr_context is None: @@ -1115,7 +1115,7 @@ class ExprCToExpr(ExprReducer): def __init__(self, expr_types, types_mngr): """Init ExprCAccess - @expr_types: a dictionnary linking ID names to their types + @expr_types: a dictionary linking ID names to their types @types_mngr: types manager """ @@ -1124,7 +1124,7 @@ class ExprCToExpr(ExprReducer): def updt_expr_types(self, expr_types): """Update expr_types - @expr_types: Dictionnary associating name to type + @expr_types: Dictionary associating name to type """ self.expr_types = expr_types @@ -1330,7 +1330,7 @@ class ExprCToExpr(ExprReducer): """Translate a Miasm expression @expr (representing a C access) into a tuple composed of a native Miasm expression and its C type. @expr: Miasm expression (representing a C access) - @c_context: a dictionnary linking known tokens (strings) to their + @c_context: a dictionary linking known tokens (strings) to their types. A token is linked to only one type. """ ret = self.reduce(expr, ctxt=c_context) @@ -1597,7 +1597,7 @@ class CHandler(object): def updt_expr_types(self, expr_types): """Update expr_types - @expr_types: Dictionnary associating name to type + @expr_types: Dictionary associating name to type """ self.expr_types = expr_types @@ -1607,7 +1607,7 @@ class CHandler(object): def expr_to_c_access(self, expr, expr_context=None): """Generate the C access object(s) for a given native Miasm expression. @expr: Miasm expression - @expr_context: a dictionnary linking known expressions to a set of types + @expr_context: a dictionary linking known expressions to a set of types """ if expr_context is None: @@ -1618,7 +1618,7 @@ class CHandler(object): def expr_to_c_and_types(self, expr, expr_context=None): """Generate the C access string and corresponding type for a given native Miasm expression. - @expr_context: a dictionnary linking known expressions to a set of types + @expr_context: a dictionary linking known expressions to a set of types """ accesses = set() @@ -1629,7 +1629,7 @@ class CHandler(object): def expr_to_c(self, expr, expr_context=None): """Convert a Miasm @expr into it's C equivalent string - @expr_context: a dictionnary linking known expressions to a set of types + @expr_context: a dictionary linking known expressions to a set of types """ return set(access[0] @@ -1637,7 +1637,7 @@ class CHandler(object): def expr_to_types(self, expr, expr_context=None): """Get the possible types of the Miasm @expr - @expr_context: a dictionnary linking known expressions to a set of types + @expr_context: a dictionary linking known expressions to a set of types """ return set(access.ctype @@ -1647,7 +1647,7 @@ class CHandler(object): """Convert a C string expression to a Miasm expression and it's corresponding c type @c_str: C string - @c_context: a dictionnary linking known tokens (strings) to its type. + @c_context: a dictionary linking known tokens (strings) to its type. """ ast = parse_access(c_str) @@ -1657,7 +1657,7 @@ class CHandler(object): def c_to_expr(self, c_str, c_context): """Convert a C string expression to a Miasm expression @c_str: C string - @c_context: a dictionnary linking known tokens (strings) to its type. + @c_context: a dictionary linking known tokens (strings) to its type. """ expr, _ = self.c_to_expr_and_type(c_str, c_context) @@ -1666,7 +1666,7 @@ class CHandler(object): def c_to_type(self, c_str, c_context): """Get the type of a C string expression @expr: Miasm expression - @c_context: a dictionnary linking known tokens (strings) to its type. + @c_context: a dictionary linking known tokens (strings) to its type. """ _, ctype = self.c_to_expr_and_type(c_str, c_context) @@ -1674,5 +1674,5 @@ class CHandler(object): class CLeafTypes(object): - """Define C types sizes/alignement for a given architecture""" + """Define C types sizes/alignment for a given architecture""" pass diff --git a/miasm2/core/sembuilder.py b/miasm2/core/sembuilder.py index 67c6c257..5694ffa3 100644 --- a/miasm2/core/sembuilder.py +++ b/miasm2/core/sembuilder.py @@ -116,7 +116,7 @@ class SemBuilder(object): This class provides a decorator @parse to use on them. The context in which the function will be parsed must be supplied on - instanciation + instantiation """ def __init__(self, ctx): diff --git a/miasm2/core/types.py b/miasm2/core/types.py index a60077ac..5d9a8d27 100644 --- a/miasm2/core/types.py +++ b/miasm2/core/types.py @@ -91,7 +91,7 @@ And access the fields: MemUnion and MemBitField can also be subclassed, the `fields` field being in the format expected by, respectively, Union and BitField. -The `addr` argument can be omited if an allocator is set, in which case the +The `addr` argument can be omitted if an allocator is set, in which case the structure will be automatically allocated in memory: my_heap = miasm2.os_dep.common.heap() @@ -277,7 +277,7 @@ class Type(object): """Set a VmMngr memory from a value. @vm: VmMngr instance - @addr: the start adress in memory to set + @addr: the start address in memory to set @val: the python value to serialize in @vm at @addr """ raw = self._pack(val) @@ -293,7 +293,7 @@ class Type(object): """Returns a class with a (vm, addr) constructor that allows to interact with this type in memory. - In compilation terms, it returns a class allowing to instanciate an + In compilation terms, it returns a class allowing to instantiate an lvalue of this type. @return: a MemType subclass. @@ -305,7 +305,7 @@ class Type(object): return pinned_type def _build_pinned_type(self): - """Builds the MemType subclass allowing to interract with this type. + """Builds the MemType subclass allowing to interact with this type. Called by self.lval when it is not in cache. """ @@ -419,7 +419,7 @@ class Ptr(Num): If a Type is given, it is transformed into a MemType with TheType.lval. *type_args, **type_kwargs: arguments to pass to the the pointed - MemType when instanciating it (e.g. for MemStr encoding or + MemType when instantiating it (e.g. for MemStr encoding or MemArray field_type). """ if (not isinstance(dst_type, Type) and @@ -490,7 +490,7 @@ class Ptr(Num): """ # Sanity check if self.dst_type != val.get_type(): - log.warning("Original type was %s, overriden by value of type %s", + log.warning("Original type was %s, overridden by value of type %s", self._dst_type.__name__, val.__class__.__name__) # Actual job @@ -980,7 +980,7 @@ class BitField(Union): """ def __init__(self, backing_num, bit_list): - """@backing num: Num intance, @bit_list: [(name, n_bits)]""" + """@backing num: Num instance, @bit_list: [(name, n_bits)]""" self._num = backing_num fields = [] offset = 0 @@ -1161,7 +1161,7 @@ class Self(Void): def _build_pinned_type(self): return MemSelf -# To avoid reinstanciation when testing equality +# To avoid reinstantiation when testing equality SELF_TYPE_INSTANCE = Self() VOID_TYPE_INSTANCE = Void() @@ -1232,7 +1232,7 @@ class MemType(object): @classmethod def set_allocator(cls, alloc_func): - """Set an allocator for this class; allows to instanciate statically + """Set an allocator for this class; allows to instantiate statically sized MemTypes (i.e. sizeof() is implemented) without specifying the address (the object is allocated by @alloc_func in the vm). @@ -1357,7 +1357,7 @@ class MemStruct(MemType): The mechanism is the following: - set a "fields" class field to be a list of (<field_name (str)>, <Type_subclass_instance>) - - instances of this class will have properties to interract with these + - instances of this class will have properties to interact with these fields. Example: diff --git a/miasm2/expression/expression.py b/miasm2/expression/expression.py index 4dc16f75..e7657860 100644 --- a/miasm2/expression/expression.py +++ b/miasm2/expression/expression.py @@ -108,7 +108,7 @@ def visit_chk(visitor): class DiGraphExpr(DiGraph): - """Enhanced graph for Expression diplay + """Enhanced graph for Expression display Expression are displayed as a tree with node and edge labeled with only relevant information""" @@ -187,7 +187,7 @@ class Expr(object): raise ValueError('size is not mutable') def __init__(self, size): - """Instanciate an Expr with size @size + """Instantiate an Expr with size @size @size: int """ # Common attribute @@ -1343,7 +1343,7 @@ class ExprCompose(Expr): def is_compose(self): return True -# Expression order for comparaison +# Expression order for comparison EXPR_ORDER_DICT = {ExprId: 1, ExprLoc: 2, ExprCond: 3, @@ -1416,7 +1416,7 @@ def compare_exprs(expr1, expr2): return cmp(expr1.size, expr2.size) elif cls1 == ExprAssign: raise NotImplementedError( - "Comparaison from an ExprAssign not yet implemented") + "Comparison from an ExprAssign not yet implemented") elif cls2 == ExprCond: ret = compare_exprs(expr1.cond, expr2.cond) if ret: @@ -1447,7 +1447,7 @@ def compare_exprs(expr1, expr2): elif cls1 == ExprCompose: return compare_expr_list_compose(expr1.args, expr2.args) raise NotImplementedError( - "Comparaison between %r %r not implemented" % (expr1, expr2)) + "Comparison between %r %r not implemented" % (expr1, expr2)) def canonize_expr_list(expr_list): @@ -1554,7 +1554,7 @@ def match_expr(expr, pattern, tks, result=None): """Try to match the @pattern expression with the pattern @expr with @tks jokers. Result is output dictionary with matching joker values. @expr : Expr pattern - @pattern : Targetted Expr to match + @pattern : Targeted Expr to match @tks : list of ExprId, available jokers @result : dictionary of ExprId -> Expr, output matching context """ @@ -1991,7 +1991,7 @@ def expr_is_sNaN(expr): def expr_is_float_lower(op1, op2): """Return 1 on 1 bit if @op1 < @op2, 0 otherwise. /!\ Assume @op1 and @op2 are not NaN - Comparision is the floating point one, defined in IEEE754 + Comparison is the floating point one, defined in IEEE754 """ sign1, sign2 = op1.msb(), op2.msb() magn1, magn2 = op1[:-1], op2[:-1] @@ -2005,7 +2005,7 @@ def expr_is_float_lower(op1, op2): def expr_is_float_equal(op1, op2): """Return 1 on 1 bit if @op1 == @op2, 0 otherwise. /!\ Assume @op1 and @op2 are not NaN - Comparision is the floating point one, defined in IEEE754 + Comparison is the floating point one, defined in IEEE754 """ sign1, sign2 = op1.msb(), op2.msb() magn1, magn2 = op1[:-1], op2[:-1] diff --git a/miasm2/expression/expression_reduce.py b/miasm2/expression/expression_reduce.py index 0099dd78..adad552e 100644 --- a/miasm2/expression/expression_reduce.py +++ b/miasm2/expression/expression_reduce.py @@ -16,7 +16,7 @@ log_reduce.setLevel(logging.WARNING) class ExprNode(object): - """Clone of Expression object with additionnal information""" + """Clone of Expression object with additional information""" def __init__(self, expr): self.expr = expr @@ -211,7 +211,7 @@ class ExprReducer(object): """Recursively apply rules to @node @node: ExprNode to analyze - @lvl: actual recusion level + @lvl: actual recursion level """ expr = node.expr @@ -267,7 +267,7 @@ class ExprReducer(object): """Find and apply reduction rules to @node @node: ExprNode to analyse - @lvl: actuel recusion level + @lvl: actuel recursion level """ for rule in self.reduction_rules: diff --git a/miasm2/expression/simplifications_common.py b/miasm2/expression/simplifications_common.py index 7bdfd33b..6f0eb34a 100644 --- a/miasm2/expression/simplifications_common.py +++ b/miasm2/expression/simplifications_common.py @@ -23,7 +23,7 @@ def simp_cst_propagation(e_s, expr): op_name = expr.op # simpl integer manip # int OP int => int - # TODO: <<< >>> << >> are architecture dependant + # TODO: <<< >>> << >> are architecture dependent if op_name in op_propag_cst: while (len(args) >= 2 and args[-1].is_int() and @@ -240,7 +240,7 @@ def simp_cst_propagation(e_s, expr): else: # Do not consider this case, too tricky (overflow on addition / - # substraction) + # subtraction) pass # A >> X >> Y => A >> (X+Y) if X + Y does not overflow @@ -284,7 +284,7 @@ def simp_cst_propagation(e_s, expr): # ! (!X + int) => X - int # TODO - # ((A & mask) >> shift) whith mask < 2**shift => 0 + # ((A & mask) >> shift) with mask < 2**shift => 0 if op_name == ">>" and args[1].is_int() and args[0].is_op("&"): if (args[0].args[1].is_int() and 2 ** args[1].arg > args[0].args[1].arg): diff --git a/miasm2/expression/simplifications_cond.py b/miasm2/expression/simplifications_cond.py index f6b1ea8b..f1c224b7 100644 --- a/miasm2/expression/simplifications_cond.py +++ b/miasm2/expression/simplifications_cond.py @@ -1,8 +1,8 @@ ################################################################################ # -# By choice, Miasm2 does not handle comparaison as a single operation, but with -# operations corresponding to comparaison computation. -# One may want to detect those comparaison; this library is designed to add them +# By choice, Miasm2 does not handle comparison as a single operation, but with +# operations corresponding to comparison computation. +# One may want to detect those comparison; this library is designed to add them # in Miasm2 engine thanks to : # - Conditions computation in ExprOp # - Simplifications to catch known condition forms @@ -132,7 +132,7 @@ def expr_simp_inverse(expr_simp, e): to_match, [jok1, jok2, jok_small]) - # Check for 2 symetric cases + # Check for 2 symmetric cases if r is False: to_match = (ExprOp_inf_signed(jok1, jok2) ^ jok_small) r = __match_expr_wrap(e, diff --git a/miasm2/ir/ir.py b/miasm2/ir/ir.py index 16dffc79..72f775fb 100644 --- a/miasm2/ir/ir.py +++ b/miasm2/ir/ir.py @@ -48,7 +48,7 @@ class AssignBlock(object): -> Exchange between EBX and EAX - AssignBlock can be seen as a dictionnary where keys are the destinations + AssignBlock can be seen as a dictionary where keys are the destinations (ExprId or ExprMem), and values their corresponding sources. Also provides common manipulation on this assignments. @@ -58,7 +58,7 @@ class AssignBlock(object): def __init__(self, irs=None, instr=None): """Create a new AssignBlock - @irs: (optional) sequence of ExprAssign, or dictionnary dst (Expr) -> src + @irs: (optional) sequence of ExprAssign, or dictionary dst (Expr) -> src (Expr) @instr: (optional) associate an instruction with this AssignBlock @@ -109,7 +109,7 @@ class AssignBlock(object): # prev_RAX = 0x1122334455667788 # input_RAX[0:8] = 0x89 # final_RAX -> ? (assignment are in parallel) - raise RuntimeError("Concurent access on same bit not allowed") + raise RuntimeError("Concurrent access on same bit not allowed") # Consider slice grouping expr_list = [(new_dst, new_src), @@ -126,7 +126,7 @@ class AssignBlock(object): for i, (_, stop) in enumerate(known_intervals[:-1]): if stop > known_intervals[i + 1][0]: raise RuntimeError( - "Concurent access on same bit not allowed") + "Concurrent access on same bit not allowed") # Fill with missing data missing_i = get_missing_interval(known_intervals, 0, new_dst.size) @@ -202,7 +202,7 @@ class AssignBlock(object): @staticmethod def get_modified_slice(dst, src): """Return an Expr list of extra expressions needed during the - object instanciation""" + object instantiation""" if not isinstance(src, m2_expr.ExprCompose): raise ValueError("Get mod slice not on expraff slice", str(src)) modified_s = [] @@ -220,7 +220,7 @@ class AssignBlock(object): return set(self.keys()) def get_rw(self, mem_read=False, cst_read=False): - """Return a dictionnary associating written expressions to a set of + """Return a dictionary associating written expressions to a set of their read requirements @mem_read: (optional) mem_read argument of `get_r` @cst_read: (optional) cst_read argument of `get_r` @@ -471,7 +471,7 @@ class IRCFG(DiGraph): """DiGraph for IR instances""" def __init__(self, irdst, loc_db, blocks=None, *args, **kwargs): - """Instanciate a IRCFG + """Instantiate a IRCFG @loc_db: LocationDB instance @blocks: IR blocks """ diff --git a/miasm2/ir/symbexec.py b/miasm2/ir/symbexec.py index 052736ee..a1ffebf5 100644 --- a/miasm2/ir/symbexec.py +++ b/miasm2/ir/symbexec.py @@ -81,7 +81,7 @@ class SymbolicState(StateEngine): @property def symbols(self): - """Return the dictionnary of known symbols""" + """Return the dictionary of known symbols""" return dict(self._symbols) @@ -945,7 +945,7 @@ class SymbolicExecutionEngine(object): def eval_expr(self, expr, eval_cache=None): """ Evaluate @expr - @expr: Expresion instance to evaluate + @expr: Expression instance to evaluate @cache: None or dictionary linking variables to their values """ if eval_cache is None: diff --git a/miasm2/ir/symbexec_top.py b/miasm2/ir/symbexec_top.py index f5ecb566..887ebe59 100644 --- a/miasm2/ir/symbexec_top.py +++ b/miasm2/ir/symbexec_top.py @@ -68,7 +68,7 @@ class SymbolicStateTop(StateEngine): @property def symbols(self): - """Return the dictionnary of known symbols""" + """Return the dictionary of known symbols""" return dict(self._symbols) @property diff --git a/miasm2/ir/symbexec_types.py b/miasm2/ir/symbexec_types.py index 2b7643ca..7580d1f8 100644 --- a/miasm2/ir/symbexec_types.py +++ b/miasm2/ir/symbexec_types.py @@ -51,7 +51,7 @@ class SymbolicStateCTypes(StateEngine): @property def symbols(self): - """Return the dictionnary of known symbols'types""" + """Return the dictionary of known symbols'types""" return dict(self._symbols) diff --git a/miasm2/ir/translators/smt2.py b/miasm2/ir/translators/smt2.py index 802481fe..eda24bb7 100644 --- a/miasm2/ir/translators/smt2.py +++ b/miasm2/ir/translators/smt2.py @@ -47,7 +47,7 @@ class SMT2Mem(object): try: mem = self.mems[size] except KeyError: - # Lazy instanciation + # Lazy instantiation self.mems[size] = self.name + str(size) mem = self.mems[size] return mem @@ -105,7 +105,7 @@ class TranslatorSMT2(Translator): expression. Memory is abstracted via SMT2Mem. The result of from_expr will be an SMT2 expression. - If you want to interract with the memory abstraction after the translation, + If you want to interact with the memory abstraction after the translation, you can instantiate your own SMT2Mem that will be equivalent to the one used by TranslatorSMT2. diff --git a/miasm2/ir/translators/z3_ir.py b/miasm2/ir/translators/z3_ir.py index 1cc8c29d..d43468ef 100644 --- a/miasm2/ir/translators/z3_ir.py +++ b/miasm2/ir/translators/z3_ir.py @@ -50,7 +50,7 @@ class Z3Mem(object): try: mem = self.mems[size] except KeyError: - # Lazy instanciation + # Lazy instantiation self.mems[size] = z3.Array(self.name + str(size), z3.BitVecSort(size), z3.BitVecSort(8)) @@ -104,8 +104,8 @@ class TranslatorZ3(Translator): expression. Memory is abstracted via z3.Array (see Z3Mem). The result of from_expr will be a z3 Expr. - If you want to interract with the memory abstraction after the translation, - you can instanciate your own Z3Mem, that will be equivalent to the one + If you want to interact with the memory abstraction after the translation, + you can instantiate your own Z3Mem, that will be equivalent to the one used by TranslatorZ3. """ diff --git a/miasm2/jitter/arch/JitCore_aarch64.c b/miasm2/jitter/arch/JitCore_aarch64.c index 76452a44..fc51848a 100644 --- a/miasm2/jitter/arch/JitCore_aarch64.c +++ b/miasm2/jitter/arch/JitCore_aarch64.c @@ -141,8 +141,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/arch/JitCore_arm.c b/miasm2/jitter/arch/JitCore_arm.c index ac7d16bf..4f1fd254 100644 --- a/miasm2/jitter/arch/JitCore_arm.c +++ b/miasm2/jitter/arch/JitCore_arm.c @@ -115,8 +115,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/arch/JitCore_mep.c b/miasm2/jitter/arch/JitCore_mep.c index da070016..44f36290 100644 --- a/miasm2/jitter/arch/JitCore_mep.c +++ b/miasm2/jitter/arch/JitCore_mep.c @@ -172,8 +172,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/arch/JitCore_mips32.c b/miasm2/jitter/arch/JitCore_mips32.c index 2a5dfd0f..1c2854aa 100644 --- a/miasm2/jitter/arch/JitCore_mips32.c +++ b/miasm2/jitter/arch/JitCore_mips32.c @@ -131,8 +131,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/arch/JitCore_msp430.c b/miasm2/jitter/arch/JitCore_msp430.c index 7072a380..12a42782 100644 --- a/miasm2/jitter/arch/JitCore_msp430.c +++ b/miasm2/jitter/arch/JitCore_msp430.c @@ -113,8 +113,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/arch/JitCore_x86.c b/miasm2/jitter/arch/JitCore_x86.c index 1782c5ae..b711f40b 100644 --- a/miasm2/jitter/arch/JitCore_x86.c +++ b/miasm2/jitter/arch/JitCore_x86.c @@ -256,8 +256,8 @@ PyObject* cpu_set_gpreg(JitCpu* self, PyObject *args) if (found) continue; - fprintf(stderr, "unkown key: %s\n", PyString_AsString(d_key)); - RAISE(PyExc_ValueError, "unkown reg"); + fprintf(stderr, "unknown key: %s\n", PyString_AsString(d_key)); + RAISE(PyExc_ValueError, "unknown reg"); } Py_INCREF(Py_None); return Py_None; diff --git a/miasm2/jitter/codegen.py b/miasm2/jitter/codegen.py index e8177ab5..32af29a2 100644 --- a/miasm2/jitter/codegen.py +++ b/miasm2/jitter/codegen.py @@ -132,9 +132,9 @@ class CGen(object): return self.translator.from_expr(self.patch_c_id(expr)) def add_label_index(self, dst2index, loc_key): - """Insert @lbl to the dictionnary @dst2index with a uniq value + """Insert @lbl to the dictionary @dst2index with a uniq value @dst2index: LocKey -> uniq value - @loc_key: LocKey istance""" + @loc_key: LocKey instance""" if loc_key not in dst2index: dst2index[loc_key] = len(dst2index) @@ -183,9 +183,9 @@ class CGen(object): def add_local_var(self, dst_var, dst_index, expr): """ - Add local varaible used to store temporay result - @dst_var: dictionnary of Expr -> local_var_expr - @dst_index : dictionnary of size -> local var count + Add local variable used to store temporay result + @dst_var: dictionary of Expr -> local_var_expr + @dst_index : dictionary of size -> local var count @expr: Expression source """ size = expr.size @@ -202,7 +202,7 @@ class CGen(object): def get_mem_prefetch(self, assignblk): """ Generate temporary variables used to fetch memory used in the @assignblk - Return a dictionnary: ExprMem -> temporary variable + Return a dictionary: ExprMem -> temporary variable @assignblk: AssignBlock instance """ mem_index = {8: 0, 16: 0, 32: 0, 64: 0, 128:0} @@ -224,7 +224,7 @@ class CGen(object): def gen_c_assignments(self, assignblk): """ - Return C informations used to generate the C code of the @assignblk + Return C information used to generate the C code of the @assignblk @assignblk: an AssignBlock instance """ c_var = [] @@ -256,7 +256,7 @@ class CGen(object): elif isinstance(dst, ExprId): new_dst = self.add_local_var(dst_var, dst_index, dst) if dst in self.ir_arch.arch.regs.regs_flt_expr: - # Dont mask float affectation + # Don't mask float affectation c_main.append( '%s = (%s);' % (self.id_to_c(new_dst), self.id_to_c(src))) elif new_dst.size <= self.translator.NATIVE_INT_MAX_SIZE: @@ -321,7 +321,7 @@ class CGen(object): def traverse_expr_dst(self, expr, dst2index): """ Generate the index of the destination label for the @expr - @dst2index: dictionnary to link label to its index + @dst2index: dictionary to link label to its index """ if isinstance(expr, ExprCond): diff --git a/miasm2/jitter/emulatedsymbexec.py b/miasm2/jitter/emulatedsymbexec.py index 6e1bfe65..15024505 100644 --- a/miasm2/jitter/emulatedsymbexec.py +++ b/miasm2/jitter/emulatedsymbexec.py @@ -21,7 +21,7 @@ class EmulatedSymbExec(SymbolicExecutionEngine): } def __init__(self, cpu, vm, *args, **kwargs): - """Instanciate an EmulatedSymbExec, associated to CPU @cpu and bind + """Instantiate an EmulatedSymbExec, associated to CPU @cpu and bind memory accesses. @cpu: JitCpu instance """ diff --git a/miasm2/jitter/jitcore_llvm.py b/miasm2/jitter/jitcore_llvm.py index 6c7d47ac..463e476a 100644 --- a/miasm2/jitter/jitcore_llvm.py +++ b/miasm2/jitter/jitcore_llvm.py @@ -10,7 +10,7 @@ import platform class JitCore_LLVM(jitcore.JitCore): "JiT management, using LLVM as backend" - # Architecture dependant libraries + # Architecture dependent libraries arch_dependent_libs = {"x86": "JitCore_x86", "arm": "JitCore_arm", "msp430": "JitCore_msp430", @@ -46,7 +46,7 @@ class JitCore_LLVM(jitcore.JitCore): # Library to load within Jit context libs_to_load = [] - # Get architecture dependant Jitcore library (if any) + # Get architecture dependent Jitcore library (if any) lib_dir = os.path.dirname(os.path.realpath(__file__)) lib_dir = os.path.join(lib_dir, 'arch') ext = '.so' if platform.system() != 'Windows' else '.pyd' @@ -66,7 +66,7 @@ class JitCore_LLVM(jitcore.JitCore): # Save the current architecture parameters self.arch = self.ir_arch.arch - # Get the correspondance between registers and vmcpu struct + # Get the correspondence between registers and vmcpu struct mod_name = "miasm2.jitter.arch.JitCore_%s" % (self.ir_arch.arch.name) mod = importlib.import_module(mod_name) self.context.set_vmcpu(mod.get_gpreg_offset_all()) diff --git a/miasm2/jitter/llvmconvert.py b/miasm2/jitter/llvmconvert.py index 04dc2d2b..6f024c1e 100644 --- a/miasm2/jitter/llvmconvert.py +++ b/miasm2/jitter/llvmconvert.py @@ -76,7 +76,7 @@ class LLVMContext(): llvm.initialize_native_target() llvm.initialize_native_asmprinter() - # Initilize target for compilation + # Initialize target for compilation target = llvm.Target.from_default_triple() self.target_machine = target.create_target_machine() self.init_exec_engine() @@ -320,7 +320,7 @@ class LLVMContext_JIT(LLVMContext): readonly=True) def set_vmcpu(self, lookup_table): - "Set the correspondance between register name and vmcpu offset" + "Set the correspondence between register name and vmcpu offset" self.vmcpu = lookup_table @@ -450,7 +450,7 @@ class LLVMContext_JIT(LLVMContext): def get_ptr_from_cache(self, file_name, func_name): "Load @file_name and return a pointer on the jitter @func_name" - # We use an empty module to avoid loosing time on function building + # We use an empty module to avoid losing time on function building empty_module = llvm.parse_assembly("") empty_module.fname_out = file_name @@ -1399,8 +1399,8 @@ class LLVMFunction(object): def gen_irblock(self, instr_attrib, attributes, instr_offsets, irblock): """ Generate the code for an @irblock - @instr_attrib: an Attributs instance or the instruction to translate - @attributes: list of Attributs corresponding to irblock assignments + @instr_attrib: an Attributes instance or the instruction to translate + @attributes: list of Attributes corresponding to irblock assignments @instr_offsets: offset of all asmblock's instructions @irblock: an irblock instance """ @@ -1610,7 +1610,7 @@ class LLVMFunction(object): new_irblock = self.llvm_context.ir_arch.irbloc_fix_regs_for_mode( irblock, self.llvm_context.ir_arch.attrib) - # Set the builder at the begining of the correct bbl + # Set the builder at the beginning of the correct bbl self.builder.position_at_end(self.get_basic_block_by_loc_key(new_irblock.loc_key)) if index == 0: @@ -1695,7 +1695,7 @@ class LLVMFunction_IRCompilation(LLVMFunction): >>> func.ret_type = llvm_ir.VoidType() >>> func.init_fc() >>> - >>> # Insert here function additionnal inits + >>> # Insert here function additional inits >>> XX = func.builder.alloca(...) >>> func.local_vars_pointers["EAX"] = XX >>> # diff --git a/miasm2/jitter/loader/elf.py b/miasm2/jitter/loader/elf.py index d1df8c3f..b94a9309 100644 --- a/miasm2/jitter/loader/elf.py +++ b/miasm2/jitter/loader/elf.py @@ -146,7 +146,7 @@ def fill_loc_db_with_symbols(elf, loc_db, base_addr=0): def apply_reloc_x86(elf, vm, section, base_addr, loc_db): - """Apply relocation for x86 ELF contained in the secion @section + """Apply relocation for x86 ELF contained in the section @section @elf: elfesteem's ELF instance @vm: VmMngr instance @section: elf's section containing relocation to perform diff --git a/miasm2/jitter/loader/pe.py b/miasm2/jitter/loader/pe.py index e4cd57ee..176e0065 100644 --- a/miasm2/jitter/loader/pe.py +++ b/miasm2/jitter/loader/pe.py @@ -126,7 +126,7 @@ def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, name="", **kargs): @load_hdr: (optional) If False, do not load the NThdr in memory Return the corresponding PE instance. - Extra arguments are passed to PE instanciation. + Extra arguments are passed to PE instantiation. If all sections are aligned, they will be mapped on several different pages Otherwise, a big page is created, containing all sections """ @@ -167,7 +167,7 @@ def vm_load_pe(vm, fdata, align_s=True, load_hdr=True, name="", **kargs): ) section.offset = section.addr - # Last section alignement + # Last section alignment last_section = pe.SHList[-1] last_section.size = (last_section.size + 0xfff) & 0xfffff000 diff --git a/miasm2/os_dep/linux/environment.py b/miasm2/os_dep/linux/environment.py index 4f125563..7cafae43 100644 --- a/miasm2/os_dep/linux/environment.py +++ b/miasm2/os_dep/linux/environment.py @@ -322,7 +322,7 @@ class LinuxEnvironment(object): """A LinuxEnvironment regroups information to simulate a Linux-like environment""" - # To be overrided + # To be overridden platform_arch = None # User information @@ -655,13 +655,13 @@ class AuxVec(object): AT_SYSINFO_EHDR = 33 def __init__(self, elf_phdr_vaddr, entry_point, linux_env, **kwargs): - """Instanciate an AuxVec, with required elements: + """Instantiate an AuxVec, with required elements: - elf_phdr_vaddr: virtual address of the ELF's PHDR in memory - entry_point: virtual address of the ELF entry point - linux_env: LinuxEnvironment instance, used to provides some of the option values - Others options can be overrided by named arguments + Others options can be overridden by named arguments """ self.info = { diff --git a/miasm2/os_dep/win_api_x86_32.py b/miasm2/os_dep/win_api_x86_32.py index 25e98d4b..5d6e4765 100644 --- a/miasm2/os_dep/win_api_x86_32.py +++ b/miasm2/os_dep/win_api_x86_32.py @@ -2559,8 +2559,8 @@ def msvcrt_wcslen(jitter): jitter.func_ret_cdecl(ret_ad, len(s)) def kernel32_SetFilePointer(jitter): - ret_ad, args = jitter.func_args_stdcall(["hwnd", "distance", - "p_distance_high", + ret_ad, args = jitter.func_args_stdcall(["hwnd", "dinstance", + "p_dinstance_high", "movemethod"]) if args.hwnd == winobjs.module_cur_hwnd: @@ -2572,22 +2572,22 @@ def kernel32_SetFilePointer(jitter): # data = None if args.hwnd in winobjs.files_hwnd: - winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(args.distance, args.movemethod) + winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(args.dinstance, args.movemethod) elif args.hwnd in winobjs.handle_pool: wh = winobjs.handle_pool[args.hwnd] - wh.info.seek(args.distance, args.movemethod) + wh.info.seek(args.dinstance, args.movemethod) else: raise ValueError('unknown filename') - jitter.func_ret_stdcall(ret_ad, args.distance) + jitter.func_ret_stdcall(ret_ad, args.dinstance) def kernel32_SetFilePointerEx(jitter): - ret_ad, args = jitter.func_args_stdcall(["hwnd", "distance_l", - "distance_h", + ret_ad, args = jitter.func_args_stdcall(["hwnd", "dinstance_l", + "dinstance_h", "pnewfileptr", "movemethod"]) - distance = args.distance_l | (args.distance_h << 32) - if distance: + dinstance = args.dinstance_l | (args.dinstance_h << 32) + if dinstance: raise ValueError('Not implemented') if args.pnewfileptr: raise ValueError('Not implemented') @@ -2600,10 +2600,10 @@ def kernel32_SetFilePointerEx(jitter): # data = None if args.hwnd in winobjs.files_hwnd: - winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(distance, args.movemethod) + winobjs.files_hwnd[winobjs.module_cur_hwnd].seek(dinstance, args.movemethod) elif args.hwnd in winobjs.handle_pool: wh = winobjs.handle_pool[args.hwnd] - wh.info.seek(distance, args.movemethod) + wh.info.seek(dinstance, args.movemethod) else: raise ValueError('unknown filename') jitter.func_ret_stdcall(ret_ad, 1) diff --git a/miasm2/os_dep/win_api_x86_32_seh.py b/miasm2/os_dep/win_api_x86_32_seh.py index 110f2b34..be524895 100644 --- a/miasm2/os_dep/win_api_x86_32_seh.py +++ b/miasm2/os_dep/win_api_x86_32_seh.py @@ -85,7 +85,7 @@ MAX_SEH = 5 def build_teb(jitter, teb_address): """ - Build TEB informations using following structure: + Build TEB information using following structure: @jitter: jitter instance @teb_address: the TEB address @@ -111,7 +111,7 @@ def build_teb(jitter, teb_address): def build_peb(jitter, peb_address): """ - Build PEB informations using following structure: + Build PEB information using following structure: @jitter: jitter instance @peb_address: the PEB address @@ -135,7 +135,7 @@ def build_peb(jitter, peb_address): def build_ldr_data(jitter, modules_info): """ - Build Loader informations using following structure: + Build Loader information using following structure: +0x000 Length : Uint4B +0x004 Initialized : UChar @@ -232,7 +232,7 @@ def create_modules_chain(jitter, name2module): out = "" for i, (fname, pe_obj) in enumerate(name2module.items(), 1): if pe_obj is None: - log.warning("Unknown module: ommited from link list (%r)", + log.warning("Unknown module: omitted from link list (%r)", fname) continue addr = base_addr + i * 0x1000 @@ -368,7 +368,7 @@ def fix_InInitializationOrderModuleList(jitter, modules_info): def add_process_env(jitter): """ - Build a process environement structure + Build a process environment structure @jitter: jitter instance """ |