Convenience class for dumping the PE information.
| 827 | |
| 828 | |
| 829 | class Dump: |
| 830 | """Convenience class for dumping the PE information.""" |
| 831 | |
| 832 | def __init__(self): |
| 833 | self.text = [] |
| 834 | |
| 835 | def add_lines(self, txt, indent=0): |
| 836 | """Adds a list of lines. |
| 837 | |
| 838 | The list can be indented with the optional argument 'indent'. |
| 839 | """ |
| 840 | for line in txt: |
| 841 | self.add_line(line, indent) |
| 842 | |
| 843 | def add_line(self, txt, indent=0): |
| 844 | """Adds a line. |
| 845 | |
| 846 | The line can be indented with the optional argument 'indent'. |
| 847 | """ |
| 848 | self.add(txt + "\n", indent) |
| 849 | |
| 850 | def add(self, txt, indent=0): |
| 851 | """Adds some text, no newline will be appended. |
| 852 | |
| 853 | The text can be indented with the optional argument 'indent'. |
| 854 | """ |
| 855 | self.text.append("{0}{1}".format(" " * indent, txt)) |
| 856 | |
| 857 | def add_header(self, txt): |
| 858 | """Adds a header element.""" |
| 859 | self.add_line("{0}{1}{0}\n".format("-" * 10, txt)) |
| 860 | |
| 861 | def add_newline(self): |
| 862 | """Adds a newline.""" |
| 863 | self.text.append("\n") |
| 864 | |
| 865 | def get_text(self): |
| 866 | """Get the text in its current state.""" |
| 867 | return "".join("{0}".format(b) for b in self.text) |
| 868 | |
| 869 | |
| 870 | STRUCT_SIZEOF_TYPES = { |