def __init__(self, filename, config_file, config_is_object=False): self.filename = filename self.rom = Rom(self.filename) if config_is_object: #If configs passed as object [needed for openCopy()] self.config = config_file #Use the objects else: #Otherwise, use the filenames. self.config = Config(config_file) romconfig = Config(filename, rom=True) if romconfig.get(['Database', 'Auto-Upgrade']): updb.doUpgrade(self.filename) self.database = Database(self.filenameBase() + '.awakedb') self.disasm = Z80Disasm(self) self.flow = ProcedureFlowCache(self)
def __init__(self, filename, config_file, config_is_object=False): self.filename = filename self.rom = Rom(self.filename) if config_is_object: #If configs passed as object [needed for openCopy()] self.config=config_file #Use the objects else: #Otherwise, use the filenames. self.config = Config(config_file) romconfig=Config(filename, rom=True) if romconfig.get(['Database','Auto-Upgrade']): updb.doUpgrade(self.filename) self.database = Database(self.filenameBase()+'.awakedb') self.disasm = Z80Disasm(self) self.flow = ProcedureFlowCache(self)
def __init__(self, filename, config_file, config_is_object=False): """ Create a new Project with specified Rom Filename and configuration :type filename: str """ self.filename = filename self.rom = Rom(self.filename) if config_is_object: #If configs passed as object [needed for openCopy()] self.config = config_file #Use the objects else: #Otherwise, use the filenames. self.config = Config(config_file) romconfig = Config( filename, rom=True ) # TODO: Doesn't this negate the purpose of the previous self.config lines? if romconfig.get(['Database', 'Auto-Upgrade']): updb.doUpgrade(self.filename) self.database = Database(self.filenameBase() + '.awakedb') self.disasm = Z80Disasm(self) self.flow = ProcedureFlowCache(self) self.debug_symbols = None
def __init__(self, proj, addr): self.addr = addr self.targets = [] romconfig = Config(proj.filename, rom=True) jumptables = romconfig.get(["Analysis", "Jumptable-List"]) try: size = jumptables[str(addr)] except KeyError: size = 256 for i in range(size): a = addr.offset(i * 2) lo = proj.rom.get(a) hi = proj.rom.get(a.offset(1)) value = address.fromVirtualAndCurrent((hi << 8) | lo, addr) if not value.inPhysicalMem(): print "breaking" break self.targets.append(ProcAddress(value))
def __init__(self, parent=None, filename=None, url=None, config_file=None): if not parent: parent = getTkRoot() tk.Toplevel.__init__(self, parent) self.parent = parent title = "Awake" if filename: title += ' - ' + os.path.basename(filename) self.title(title) if filename: self.romconfig=Config(filename, rom=True) self.proj = Project(filename, config_file) if self.proj.config.get(['Autostart-Server']): self.showServer() else: self.proj = None self.panes = tk.PanedWindow(self, orient='horizontal', sashwidth=10) self.panes.pack(side='top', fill='both', expand=True) self.tool_pane = ttk.Frame(self.panes) self.panes.add(self.tool_pane) self.main_pane = ttk.Frame(self.panes) self.panes.add(self.main_pane) toolbar = ttk.Frame(self.main_pane) toolbar.pack(side='top', fill='x', padx=5, pady=5) open_button = ttk.Button(toolbar, text="Open...", command=self.selectRom) open_button.pack(side='left') self.history = History(toolbar) self.history.pack(side='left') self.server_button = ttk.Button(toolbar, text="Start server...", width=15, command=self.showServer) self.server_button.pack(side='right') self.export_button = ttk.Button(toolbar, text="Export...", width=10, command=self.showExport) self.export_button.pack(side='right') self.main = MainFrame(self.main_pane, self.proj) self.main.pack(side='top', fill='both', expand=True) self.main.setLinkCallback(self.history.navigate) self.history.setOpenPageCallback(self.main.openPage) #bank_frame = ttk.Frame(self.tool_pane) #bank_frame.pack(side='top', fill='x', padx=5, pady=5) #self.bank_select = ttk.Combobox(bank_frame, state='readonly', values=['All banks', 'Bank 00', 'Bank 01'], width=10) #self.bank_select.pack(side='left', fill='x', expand=True) #bank_names_button = ttk.Button(bank_frame, text='...', width=3) #bank_names_button.pack(side='left') #symbol_frame = ttk.Frame(self.tool_pane) #symbol_frame.pack(side='top', fill='x') #self.symbol_list = tk.Listbox(symbol_frame, relief='flat', highlightthickness=0) #self.symbol_list.pack(side='left', fill='both', expand=True) #symbol_sb = ttk.Scrollbar(symbol_frame, orient="vertical", command=self.symbol_list.yview) #symbol_sb.pack(side="right", fill="y") #self.symbol_list.configure(yscrollcommand=symbol_sb.set) self.protocol("WM_DELETE_WINDOW", self.quit) if not url and self.proj: url = self.romconfig.get(['UI','Default-Page']) if url: self.history.navigate(url) if not self.proj: self.export_button.configure(state='disabled') self.server_button.configure(state='disabled') self.history.disable()
class MainWindow(tk.Toplevel): def __init__(self, parent=None, filename=None, url=None, config_file=None): if not parent: parent = getTkRoot() tk.Toplevel.__init__(self, parent) self.parent = parent title = "Awake" if filename: title += ' - ' + os.path.basename(filename) self.title(title) if filename: self.romconfig = Config(filename, rom=True) self.proj = Project(filename, config_file) if self.proj.config.get(['Autostart-Server']): self.showServer() else: self.proj = None self.panes = tk.PanedWindow(self, orient='horizontal', sashwidth=10) self.panes.pack(side='top', fill='both', expand=True) self.tool_pane = ttk.Frame(self.panes) self.panes.add(self.tool_pane) self.main_pane = ttk.Frame(self.panes) self.panes.add(self.main_pane) toolbar = ttk.Frame(self.main_pane) toolbar.pack(side='top', fill='x', padx=5, pady=5) open_button = ttk.Button(toolbar, text="Open...", command=self.selectRom) open_button.pack(side='left') self.debug_symbols_button = ttk.Button(toolbar, text="Import debug symbols...", command=self.importDebugSymbols) self.debug_symbols_button.pack(side='left') self.history = History(toolbar) self.history.pack(side='left') self.server_button = ttk.Button(toolbar, text="Start server...", width=15, command=self.showServer) self.server_button.pack(side='right') self.export_button = ttk.Button(toolbar, text="Export...", width=10, command=self.showExport) self.export_button.pack(side='right') self.main = MainFrame(self.main_pane, self.proj) self.main.pack(side='top', fill='both', expand=True) self.main.setLinkCallback(self.history.navigate) self.history.setOpenPageCallback(self.main.openPage) #bank_frame = ttk.Frame(self.tool_pane) #bank_frame.pack(side='top', fill='x', padx=5, pady=5) #self.bank_select = ttk.Combobox(bank_frame, state='readonly', values=['All banks', 'Bank 00', 'Bank 01'], width=10) #self.bank_select.pack(side='left', fill='x', expand=True) #bank_names_button = ttk.Button(bank_frame, text='...', width=3) #bank_names_button.pack(side='left') #symbol_frame = ttk.Frame(self.tool_pane) #symbol_frame.pack(side='top', fill='x') #self.symbol_list = tk.Listbox(symbol_frame, relief='flat', highlightthickness=0) #self.symbol_list.pack(side='left', fill='both', expand=True) #symbol_sb = ttk.Scrollbar(symbol_frame, orient="vertical", command=self.symbol_list.yview) #symbol_sb.pack(side="right", fill="y") #self.symbol_list.configure(yscrollcommand=symbol_sb.set) self.protocol("WM_DELETE_WINDOW", self.quit) if not url and self.proj: url = self.romconfig.get(['UI', 'Default-Page']) if url: self.history.navigate(url) if not self.proj: self.debug_symbols_button.configure(state='disabled') self.export_button.configure(state='disabled') self.server_button.configure(state='disabled') self.history.disable() def showExport(self): if self.proj: ExportDialog(self, self.proj) def showServer(self): if self.proj: ServerDialog(self, self.proj) def selectRom(self): filename = askopenfilename(title="Select ROM file", parent=self, filetypes=[ ('Gameboy rom files (*.gb)', '*.gb'), ('Gameboy Color rom files (*.gbc)', '*.gbc'), ('All files', '*.*') ]) if not filename: return fresh = MainWindow(getTkRoot(), filename) fresh.geometry(self.geometry()) self.destroy() def importDebugSymbols(self): if not self.proj: return filename = askopenfilename(title="Select debug symbols", parent=self, filetypes=[('RGBDS debug symbols (*.sym)', '*.sym'), ('All files', '*.*')]) if not filename: return self.proj.importDebugSymbols(filename) self.main.reloadPage() def wait(self): self.wait_window(self) def quit(self, *args): self.destroy() self.parent.destroy()