Resolves a label for this module only. If the label refers to another module, an exception is raised. @type label: str @param label: Label to resolve. @rtype: int @return: Memory address pointed to by the label. @raise ValueError: The lab
(self, label)
| 723 | return address - hlib + self.lpBaseOfDll |
| 724 | |
| 725 | def resolve_label(self, label): |
| 726 | """ |
| 727 | Resolves a label for this module only. If the label refers to another |
| 728 | module, an exception is raised. |
| 729 | |
| 730 | @type label: str |
| 731 | @param label: Label to resolve. |
| 732 | |
| 733 | @rtype: int |
| 734 | @return: Memory address pointed to by the label. |
| 735 | |
| 736 | @raise ValueError: The label is malformed or impossible to resolve. |
| 737 | @raise RuntimeError: Cannot resolve the module or function. |
| 738 | """ |
| 739 | |
| 740 | # Split the label into it's components. |
| 741 | # Use the fuzzy mode whenever possible. |
| 742 | aProcess = self.get_process() |
| 743 | if aProcess is not None: |
| 744 | (module, procedure, offset) = aProcess.split_label(label) |
| 745 | else: |
| 746 | (module, procedure, offset) = _ModuleContainer.split_label(label) |
| 747 | |
| 748 | # If a module name is given that doesn't match ours, |
| 749 | # raise an exception. |
| 750 | if module and not self.match_name(module): |
| 751 | raise RuntimeError("Label does not belong to this module") |
| 752 | |
| 753 | # Resolve the procedure if given. |
| 754 | if procedure: |
| 755 | address = self.resolve(procedure) |
| 756 | if address is None: |
| 757 | # If it's a debug symbol, use the symbol. |
| 758 | address = self.resolve_symbol(procedure) |
| 759 | |
| 760 | # If it's the keyword "start" use the entry point. |
| 761 | if address is None and procedure == "start": |
| 762 | address = self.get_entry_point() |
| 763 | |
| 764 | # The procedure was not found. |
| 765 | if address is None: |
| 766 | if not module: |
| 767 | module = self.get_name() |
| 768 | msg = "Can't find procedure %s in module %s" |
| 769 | raise RuntimeError(msg % (procedure, module)) |
| 770 | |
| 771 | # If no procedure is given use the base address of the module. |
| 772 | else: |
| 773 | address = self.get_base() |
| 774 | |
| 775 | # Add the offset if given and return the resolved address. |
| 776 | if offset: |
| 777 | address = address + offset |
| 778 | return address |
| 779 | |
| 780 | |
| 781 | # ============================================================================== |
no test coverage detected