def __init__(self, ea_start, ea_end, depth=DEPTH_FULL, analysis=ANALYSIS_NONE, function=None): ''' Analyze the basic block from ea_start to ea_end. @see: defines.py @type ea_start: DWORD @param ea_start: Effective address of start of basic block (inclusive) @type ea_end: DWORD @param ea_end: Effective address of end of basic block (inclusive) @type depth: Integer @param depth: (Optional, Def=DEPTH_FULL) How deep to analyze the module @type analysis: Integer @param analysis: (Optional, Def=ANALYSIS_NONE) Which extra analysis options to enable @type function: pida.function @param function: (Optional, Def=None) Pointer to parent function container ''' # run the parent classes initialization routine first. super(basic_block, self).__init__(ea_start) heads = [ head for head in Heads(ea_start, ea_end + 1) if isCode(GetFlags(head)) ] self.id = ea_start self.ea_start = ea_start self.ea_end = ea_end self.depth = depth self.analysis = analysis self.function = function self.num_instructions = len(heads) self.instructions = {} self.ext = {} # convenience alias. self.nodes = self.instructions # bubble up the instruction count to the function. this is in a try except block to catch situations where the # analysis was not bubbled down from a function. try: self.function.num_instructions += self.num_instructions except: pass if self.depth & DEPTH_INSTRUCTIONS: for ea in heads: self.instructions[ea] = instr = instruction( ea, self.analysis, self)
def unpack(reader): subtype, = reader.peek('!H', 0) subclass = instruction.subtypes.get(subtype) if subclass: return subclass.unpack(reader) obj = instruction() obj.type = reader.read("!H")[0] _len = reader.read("!H")[0] orig_reader = reader reader = orig_reader.slice(_len, 4) return obj
def __init__(self, ea_start, ea_end, depth=DEPTH_FULL, analysis=ANALYSIS_NONE, function=None): """ Analyze the basic block from ea_start to ea_end. @see: defines.py @type ea_start: DWORD @param ea_start: Effective address of start of basic block (inclusive) @type ea_end: DWORD @param ea_end: Effective address of end of basic block (inclusive) @type depth: Integer @param depth: (Optional, Def=DEPTH_FULL) How deep to analyze the module @type analysis: Integer @param analysis: (Optional, Def=ANALYSIS_NONE) Which extra analysis options to enable @type function: pida.function @param function: (Optional, Def=None) Pointer to parent function container """ # run the parent classes initialization routine first. super(basic_block, self).__init__(ea_start) heads = [head for head in Heads(ea_start, ea_end + 1) if isCode(GetFlags(head))] self.id = ea_start self.ea_start = ea_start self.ea_end = ea_end self.depth = depth self.analysis = analysis self.function = function self.num_instructions = len(heads) self.instructions = {} self.ext = {} # convenience alias. self.nodes = self.instructions # bubble up the instruction count to the function. this is in a try except block to catch situations where the # analysis was not bubbled down from a function. try: self.function.num_instructions += self.num_instructions except: pass if self.depth & DEPTH_INSTRUCTIONS: for ea in heads: self.instructions[ea] = instr = instruction(ea, self.analysis, self)
def codegen(infile): #ebx=1 ,ecx=2, esi=3, edi=4, eax=5, edx=6 i=0 filename = infile f = open(filename, 'r') data = f.read() lines=data.split('\n') g.splitins2 = [] for i in lines: f=i.split(",") g.splitins2.append(f) g.splitins=[] x=[] for l in g.splitins2: x=[] for i in l: i=i.strip(" ") x.append(i) temp=instruction() temp.convert(x) if(len(x)!=1): g.splitins.append(temp) g.basicblock.append(len(g.splitins)) # for i in g.splitins: # i.printobj() unique = set(g.variables) g.variables = list(unique) unique2=set(g.basicblock) g.basicblock = list(unique2) unique3 = set(g.marker) g.marker = list(unique3) g.basicblock.sort() g.debug(g.basicblock) g.debug(g.marker) build_nextusetable() g.debug("*********************************************************************************") for i in g.nextuse: g.debug(i) g.debug("*********************************************************************************") convertassem()
from start import * from instruction import * from c_b import * from ready import * from scoreBoard import * import tkinter mycolor = '#%02x%02x%02x' % (255, 214, 153) root = tkinter.Tk() root.title("C&B") root.geometry("1000x550") #root.wm_attributes('-transparent', True) root.configure(bg=mycolor) startFrame = start(root) play = player(root) inst = instruction(root) rdy = ready(root) cb = c_b(root) sb = scoreBoard(root) cb.setscorBoard(sb) inst.setpara(startFrame) startFrame.setpara(inst, play) play.setpara(rdy) rdy.setpara(play, cb) startFrame.display() root.mainloop()
#!/usr/bin/env python import rospy import instruction as instruction from std_msgs import Bool, String DIRECTION = None VELOCITY = None MSG = instruction() pub = rospy.Publisher('file_instructions', instruction, queue_size=10) file = open("instructions.csv", "r") def convertToMessage(fileLine): DIRECTION = fileLine.split(" ")[0] VELOCITY = fileLine.split(" ")[1] MSG.direction = DIRECTION MSG.velocity = VELOCITY def instruction_callback(data): if (data): nextLine = file.readline() convertToMessage(nextLine) pub.publish(MSG) if __name__ == '__main__': rospy.init_node('file_instructions_node', anonymous=True) firstLine = file.readline() convertToMessage(firstLine)