Beispiel #1
0
 def open_new_constraint_dialog(self):
     address = self.cursor
     constraint = Constraint(self.rom_variant, self.address_resolver.to_local(
         address), None, None, 5, settings.get_username(), None, True)
     dialog = EditConstraintDialog(self.dock, constraint)
     dialog.constraint_changed.connect(self.add_new_constraint)
     dialog.show()
Beispiel #2
0
 def open_new_annotation_dialog(self):
     address = self.cursor
     length = abs(self.selected_bytes)
     if self.selected_bytes < 0:
         address += self.selected_bytes + 1
     annotation = Annotation(self.rom_variant, self.address_resolver.to_local(
         address), length, self.default_annotation_color, settings.get_username())
     dialog = EditAnnotationDialog(self.dock, annotation)
     dialog.annotation_changed.connect(self.add_new_annotation)
     dialog.show()
Beispiel #3
0
    def get_new_pointer_dialog(self):
        address = self.cursor
        if self.selected_bytes == -4:
            address -= 3
        points_to = self.get_as_pointer(address)

        pointer = Pointer(self.rom_variant, self.address_resolver.to_local(
            address), points_to, 5, settings.get_username())

        return EditPointerDialog(self.dock, pointer)
Beispiel #4
0
    def setup_general_tab(self):
        self.ui.lineEditUserName.setText(settings.get_username())

        self.ui.spinBoxDefaultSelectionSize.setValue(
            settings.get_default_selection_size())
        self.ui.checkBoxAlwaysLoadSymbols.setChecked(
            settings.is_always_load_symbols())
        self.ui.checkBoxHighlight8Bytes.setChecked(
            settings.is_highlight_8_bytes())
        self.ui.spinBoxBytesPerLine.setValue(settings.get_bytes_per_line())
        self.ui.checkBoxAutoSave.setChecked(settings.is_auto_save())
        self.ui.checkBoxUseConstraints.setChecked(
            settings.is_using_constraints())

        self.ui.lineEditRepoLocation.setText(settings.get_repo_location())
        self.ui.toolButtonRepoLocation.clicked.connect(self.edit_repo_location)
        self.ui.lineEditBuildCommand.setText(settings.get_build_command())
        self.ui.lineEditTidyCommand.setText(settings.get_tidy_command())
Beispiel #5
0
    def slot_multiple_pointers_discovered(self, controller: HexViewerController, base_address: int, count: int) -> None:
        print(base_address)
        for i in range(0, count):
            address = base_address + i * 4
            points_to = controller.get_as_pointer(address)

            if points_to < ROM_OFFSET or points_to > ROM_OFFSET + ROM_SIZE:
                        QMessageBox.critical(self.parent(), 'Add pointer and constraints', f'Address {hex(points_to)} is not inside the rom.')
                        return
            pointer = Pointer(controller.rom_variant, controller.address_resolver.to_local(
                address), points_to, 5, settings.get_username())
            
            try:
                if self.add_pointers_and_constraints(pointer):
                    if i == count -1:
                        QMessageBox.information(self.parent(), 'Add constraints', 'A constraint that changes the relations was added.')
                    elif QMessageBox.question(self.parent(), 'Add pointer and constraints', 'A constraint that changes the relations was added.\nDo you want to continue adding the rest of the pointers?') != QMessageBox.Yes:
                        return

            except InvalidConstraintError as e:
                QMessageBox.critical(self.parent(), 'Add constraints', 'Invalid Constraint')
                return
Beispiel #6
0
    def mark_only_in_one(self, controller: HexViewerController, virtual_address: int, length: int) -> None:

        rom_variant = controller.rom_variant

        # TODO show dialog for inputs
        certainty = 1
        author = settings.get_username()
        note = 'Only in ' + rom_variant
        enabled = True

        # Get the end of the section only in this variant + 1
        local_address = self.constraint_manager.to_local(
            rom_variant, virtual_address + length)

        new_constraints = []
        for variant in self.linked_variants:
            if variant != rom_variant:
                # Link it to the start of the selection in all other variants
                la = self.constraint_manager.to_local(variant, virtual_address)
                constraint = Constraint(
                    rom_variant, local_address, variant, la, certainty, author, note, enabled)
                new_constraints.append(constraint)

        # Check whether the new constraint is invalid
        constraint_manager = ConstraintManager({RomVariant.USA, RomVariant.DEMO, RomVariant.EU, RomVariant.JP, RomVariant.DEMO_JP, RomVariant.CUSTOM, RomVariant.CUSTOM_EU, RomVariant.CUSTOM_JP, RomVariant.CUSTOM_DEMO_USA, RomVariant.CUSTOM_DEMO_JP})
        constraint_manager.add_all_constraints(
            get_constraint_database().get_constraints())
        try:
            constraint_manager.add_all_constraints(new_constraints)
        except InvalidConstraintError as e:
            raise e

        constraint_database = get_constraint_database()
        constraint_database.add_constraints(new_constraints)

        print(f'mark only in one {rom_variant} {virtual_address} {length}')