TraceWidget.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:idasec 作者: RobinDavid 项目源码 文件源码
def load_trace(self):
        filename = QtWidgets.QFileDialog.getOpenFileName()[0]
        filepath = Path(filename)

        if filepath.exists() and filepath.isfile():
            trace = Trace(filename)
            try:
                # ==== Gui stuff
                self.loading_stat.setVisible(True)
                self.progressbar_loading.setVisible(True)
                self.progressbar_loading.reset()
                self.progressbar_loading.setMaximum(filepath.getsize())

                newtable = QtWidgets.QTableWidget(self)
                newtable.verticalHeader().setVisible(False)
                newtable.setColumnCount(len(self.trace_header_table))
                newtable.setHorizontalHeaderLabels(self.trace_header_table)
                newtable.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
                newtable.currentItemChanged.connect(self.update_instruction_informations)
                newtable.itemDoubleClicked.connect(self.go_to_instruction)
                index = self.traces_tab.addTab(newtable, filepath.name)
                id = self.parent.add_trace(trace)
                self.id_map[index] = id
                self.index_map[index] = newtable
                self.traces_tab.setCurrentIndex(index)
                # =====
                total_instr = 0
                nb_row = 0
                current_size = 0
                for chk, sz_chk, i, j, sz in trace.parse_file_generator(filename):
                    total_instr += j-i
                    current_size += sz
                    self.loading_stat.setText("Chunk nb:"+str(chk)+" | Instr nb:"+str(total_instr))
                    self.loading_stat.adjustSize()
                    self.progressbar_loading.setValue(current_size)
                    newtable.setRowCount(nb_row+sz_chk)
                    self.add_chunk_trace_table(newtable, trace, i, nb_row)
                    nb_row += sz_chk
                    newtable.scrollToBottom()

                self.trace_switch(index)

                # ===== Gui stuff
                newtable.scrollToTop()
                self.loading_stat.setVisible(False)
                self.progressbar_loading.setVisible(False)
                # ============
            except DecodeError:
                print "Fail to parse the given trace"
        else:
            print "File not existing or not a file"
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号