def out(self): buf = idaapi.init_output_buffer(1024) postfix = "" if self.cmd.auxpref & self.FL_D: postfix += "d" if self.cmd.auxpref & self.FL_E: postfix += "e" if self.cmd.auxpref & self.FL_P: postfix += "p" if self.cmd.auxpref & self.FL_C: postfix += "c" OutMnem(15, postfix) out_one_operand(0) for i in range(1, 4): op = self.cmd[i] if op.type == o_void: break out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 MakeLine(buf)
def out(self): # Init output buffer buf = idaapi.init_output_buffer(1024) # First, output the instruction mnemonic OutMnem() #Destination out_symbol('[') OutValue(self.cmd.Operands[0], OOF_ADDR | OOFW_16) out_symbol(']') out_symbol(',') OutChar(' ') #Source out_symbol('[') OutValue(self.cmd.Operands[1], OOF_ADDR | OOFW_16) out_symbol(']') if self.cmd.itype == self.itype_subleq: out_symbol(',') OutChar(' ') OutValue(self.cmd.Operands[2], OOF_ADDR | OOFW_16) # Terminate the output buffer term_output_buffer() # Emit the line cvar.gl_comm = 1 MakeLine(buf)
def out(self): """ Generate text representation of an instruction in 'cmd' structure. This function shouldn't change the database, flags or anything else. All these actions should be performed only by u_emu() function. Returns: nothing """ # Init output buffer buf = idaapi.init_output_buffer(1024) OutMnem() # output first operand # kernel will call outop() if self.cmd.Op1.type != o_void: out_one_operand(0) # output the rest of operands separated by commas for i in xrange(1, 3): if self.cmd[i].type == o_void: break out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 # generate comment at the next call to MakeLine() MakeLine(buf)
def out(self): """Outputs instruction. self.cmd will be initialized by ana(). Overrides: idaapi.processor_t """ dbgprint("out") op_obj = self.ntable[self.instruc[self.cmd.itype]["name"]] buf = idaapi.init_output_buffer(1024) if self.cmd.ea in self.indent_list: out_keyword(" ") OutMnem(3) # HACK: ua_next_word only returns the low order byte of the word. If # IDA is told this CPU uses 16-bits each byte, ua_next_byte skips # every other byte and ua_next_word still doesn't work. # In the event of a change to PC, the immediate set is in words. # Since IDA isn't using 16-bits per byte, the immediate's value doesn't # match the instruction's byte address. Detect this and adjust the # displayed value of the constant. modifies_pc = self.cmd[0].reg == self.REGISTER_PC if not op_obj.IsNonBasic(): # out_one_operand(1) self.outop(self.cmd[0]) out_symbol(",") out_symbol(" ") operand = self.cmd[1] if modifies_pc and operand.type == o_imm and op_obj.name == "SET": operand.value *= 2 self.outop(operand) operand.value /= 2 else: # out_one_operand(2) self.outop(operand) else: operand = self.cmd[0] if operand.type == o_imm and op_obj.name == "JSR": operand.value *= 2 self.outop(operand) operand.value /= 2 else: self.outop(operand) term_output_buffer() cvar.gl_comm = 1 MakeLine(buf) dbgprint("out ->")
def out(self): cmd = self.cmd buf = idaapi.init_output_buffer(1024) feat = cmd.get_canon_feature() OutMnem() if feat & (CF_USE1 | CF_CHG1): out_one_operand(0) if feat & (CF_USE2 | CF_CHG2): out_symbol(',') OutChar(' ') out_one_operand(1) term_output_buffer() cvar.gl_comm = 1 MakeLine(buf)
def out(self): buf = idaapi.init_output_buffer(1024) idaapi.OutMnem() # instruction = all_instructions[self.cmd.itype] # print instruction.mnemonic # idaapi.OutValue(instruction.mnemonic) # for i in xrange(0, 6): if self.cmd[i].type == o_void: break idaapi.out_one_operand(i) idaapi.term_output_buffer() idaapi.MakeLine(buf)
def out(self): print("out called at %x" % cmd.ea) buf = idaapi.init_output_buffer(1024) OutMnem(15) if self.cmd[0].type != o_void: out_one_operand(0) for i in range(1, 4): op = self.cmd[i] if op.type == o_void: break out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() MakeLine(buf)
def out(self): """ Generate text representation of an instruction in 'cmd' structure. This function shouldn't change the database, flags or anything else. All these actions should be performed only by u_emu() function. Returns: nothing """ self.profiler.enable() # self.log_custom("out({:s})".format(hex(self.cmd.ea))) buf = idaapi.init_output_buffer(1024) hi = self.disasm_one_inst(idaapi.get_long(self.cmd.ea), self.cmd.ea) # TODO: can I assume the cmd object is already set with the ana() information? as not to call the disasm again # and disrupt the packet disasm flow order if hi.template is None or hi.is_unknown or os.getenv( "IDP_OUT_SIMPLE_SYNTAX"): out_keyword(str(hi.text)) # This simple syntax is useful to produce generic asm code for comparison else: self.out_operands_separately(hi) # The str() conversion is necessary because the HexagonDisassembler uses the # python future compatibility module that uses unicode as default strings, # and IDA can't handle that. # TODO: maybe I shoud convert everythin to str() in the disasm (or don't use the future.unicode import) # TODO: Split in out() and out_one_operand() term_output_buffer() cvar.gl_comm = 1 # show IDA comments (http://www.hexblog.com/?p=116) MakeLine(buf) self.profiler.disable() return
def out(self): """ Generate text representation of an instruction in 'cmd' structure. This function shouldn't change the database, flags or anything else. All these actions should be performed only by u_emu() function. Returns: nothing """ self.profiler.enable() # self.log_custom("out({:s})".format(hex(self.cmd.ea))) buf = idaapi.init_output_buffer(1024) hi = self.disasm_one_inst(idaapi.get_long(self.cmd.ea), self.cmd.ea) # TODO: can I assume the cmd object is already set with the ana() information? as not to call the disasm again # and disrupt the packet disasm flow order if hi.template is None or hi.is_unknown or os.getenv("IDP_OUT_SIMPLE_SYNTAX"): out_keyword(str(hi.text)) # This simple syntax is useful to produce generic asm code for comparison else: self.out_operands_separately(hi) # The str() conversion is necessary because the HexagonDisassembler uses the # python future compatibility module that uses unicode as default strings, # and IDA can't handle that. # TODO: maybe I shoud convert everythin to str() in the disasm (or don't use the future.unicode import) # TODO: Split in out() and out_one_operand() term_output_buffer() cvar.gl_comm = 1 # show IDA comments (http://www.hexblog.com/?p=116) MakeLine(buf) self.profiler.disable() return
def out(self): """ Generate text representation of an instruction in 'cmd' structure. This function shouldn't change the database, flags or anything else. All these actions should be performed only by emu() function. Returns: nothing """ # Init output buffer buf = idaapi.init_output_buffer(1024) postfix = "" # add postfix if necessary if self.cmd.auxpref == AUX_BYTE: postfix = ".b" elif self.cmd.auxpref == AUX_WORD: postfix = ".w" # first argument (12) is the width of the mnemonic field OutMnem(12, postfix) # output first operand # kernel will call outop() if self.cmd.Op1.type != o_void: out_one_operand(0) # output the rest of operands separated by commas for i in xrange(1, 3): if self.cmd[i].type == o_void: break out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 # generate comment at the next call to MakeLine() MakeLine(buf)
def out(self): """ Output instruction in textform. """ buf = idaapi.init_output_buffer(1024) if self.cmd.auxpref & self.FLo_PluginCall: lib, _ = self.get_string(self.cmd[0].addr) fn, _ = self.get_string(self.cmd[1].addr) lib = ntpath.splitext(ntpath.basename(lib))[0] out_line('{}::{}'.format(lib, fn), COLOR_INSN) OutChar(' ') out_one_operand(2) else: OutMnem(12) for i, op in ((i, self.cmd[i]) for i in range(6)): if op.type == o_void: break if i > 0: out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 MakeLine(buf)
def out(self): """ Output instruction in textform. """ buf = idaapi.init_output_buffer(1024) if self.cmd.auxpref & self.FLo_PluginCall: lib,_ = self.get_string(self.cmd[0].addr) fn,_ = self.get_string(self.cmd[1].addr) lib = ntpath.splitext(ntpath.basename(lib))[0] out_line('{}::{}'.format(lib, fn), COLOR_INSN) OutChar(' ') out_one_operand(2) else: OutMnem(12) for i, op in ((i, self.cmd[i]) for i in range(6)): if op.type == o_void: break if i > 0: out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 MakeLine(buf)
def out(self): """ Generate text representation of an instruction in 'cmd' structure. This function shouldn't change the database, flags or anything else. All these actions should be performed only by u_emu() function. Returns: nothing """ # Init output buffer buf = idaapi.init_output_buffer(1024) suffix = '' adj_rb = get_adj_rb(self.cmd.insnpref) if adj_rb > 0: suffix += ['', 'i', 'd'][adj_rb] if self.is_conditional_branch(): suffix += CC_NAMES[get_cc(self.cmd.insnpref)] if self.cmd.insnpref & UF != 0: suffix += '.' OutMnem(8, suffix) # pretty-print [rA + Offset, RegCount] if self.is_load_store(): regcount = self.cmd.Op3.value offset = self.cmd.Op4.value if regcount > 1: start_reg = self.cmd.Op1.reg regs = [(start_reg + i) % len(GREGS) for i in xrange(regcount)] out_symbol('{') for i, reg in enumerate(regs): out_register(GREGS[reg]) if i != len(regs) - 1: out_symbol(',') out_symbol('}') else: out_one_operand(0) out_symbol(',') OutChar(' ') out_symbol('[') out_one_operand(1) # register if offset != 0: out_symbol('+') out_one_operand(3) # offset out_symbol(']') elif self.cmd.itype == Ismp: out_one_operand(0) out_symbol(',') OutChar(' ') out_one_operand(1) out_symbol(',') OutChar(' ') s = ['MEM_NO_ACCESS', 'MEM_RO', 'MEM_RW', 'MEM_RE'] for c in s[self.cmd.Op3.value]: OutChar(c) else: # output first operand # kernel will call outop() if self.cmd.Op1.type != o_void: out_one_operand(0) # output the rest of operands separated by commas for i in xrange(1, 5): if self.cmd[i].type == o_void: break out_symbol(',') OutChar(' ') out_one_operand(i) term_output_buffer() cvar.gl_comm = 1 # generate comment at the next call to MakeLine() MakeLine(buf)