def _repr_properties(self):
     properties = [
         (PT_STRING, PT_DESCRIPTION.get(self.p_type, self.p_type)),
         (PO_STRING, hex_addr(self.p_offset)),
         (PV_STRING, hex_addr(self.p_vaddr)),
         (PP_STRING, hex_addr(self.p_paddr)),
         (PF_STRING, hex_addr(self.p_filesz)),
         (PM_STRING, hex_addr(self.p_memsz)),
         (PA_STRING, hex(self.p_align)),
         (PFL_STRING, hex_addr(self.p_flags)),
         (PF_PERM_STRING, PF_PERM_DESCRIPTION.get(self.f_perm,
                                                  self.f_perm)),
         (PF_OS_POOL_INDEX_STRING,
          PF_OS_POOL_INDEX_DESCRIPTION.get(self.f_os_pool_index,
                                           self.f_os_pool_index)),
         (PF_OS_SEGMENT_TYPE_STRING,
          PF_OS_SEGMENT_TYPE_DESCRIPTION.get(self.f_os_segment_type,
                                             self.f_os_segment_type)),
         (PF_OS_ACCESS_TYPE_STRING,
          PF_OS_ACCESS_TYPE_DESCRIPTION.get(self.f_os_access_type,
                                            self.f_os_access_type)),
         (PF_OS_PAGE_MODE_STRING,
          PF_OS_PAGE_MODE_DESCRIPTION.get(self.f_os_page_mode,
                                          self.f_os_page_mode)),
     ]
     return [(attr, val) for attr, val in properties]
 def _repr_properties(self):
     properties = [
                   (PT_STRING, PT_DESCRIPTION.get(self.p_type, self.p_type)),
                   (PO_STRING, hex_addr(self.p_offset)),
                   (PV_STRING, hex_addr(self.p_vaddr)),
                   (PP_STRING, hex_addr(self.p_paddr)),
                   (PF_STRING, hex_addr(self.p_filesz)),
                   (PM_STRING, hex_addr(self.p_memsz)),
                   (PA_STRING, hex(self.p_align)),
                   (PFL_STRING, hex_addr(self.p_flags)),
                   (PF_PERM_STRING, PF_PERM_DESCRIPTION.get(self.f_perm, self.f_perm)),
                   (PF_OS_POOL_INDEX_STRING, PF_OS_POOL_INDEX_DESCRIPTION.get(self.f_os_pool_index, self.f_os_pool_index)),
                   (PF_OS_SEGMENT_TYPE_STRING, PF_OS_SEGMENT_TYPE_DESCRIPTION.get(self.f_os_segment_type, self.f_os_segment_type)),
                   (PF_OS_ACCESS_TYPE_STRING, PF_OS_ACCESS_TYPE_DESCRIPTION.get(self.f_os_access_type, self.f_os_access_type)),
                   (PF_OS_PAGE_MODE_STRING, PF_OS_PAGE_MODE_DESCRIPTION.get(self.f_os_page_mode, self.f_os_page_mode)),
                  ]
     return [(attr, val) for attr, val in properties]
Exemple #3
0
def repr_phdrs(phdrs):
    retval = TablePrinter()
    
    COLUMN_SNO      = 0
    COLUMN_TYPE     = 1
    COLUMN_OFF      = 2
    COLUMN_VADDR    = 3
    COLUMN_PADDR    = 4
    COLUMN_FSIZE    = 5
    COLUMN_MSIZE    = 6
    COLUMN_FLAGS    = 7
    COLUMN_ALIGN    = 8
    
    retval.insert_data(0, COLUMN_SNO, 'S.No')
    retval.insert_data(0, COLUMN_TYPE, 'Type')
    retval.insert_data(0, COLUMN_OFF, 'Offset')
    retval.insert_data(0, COLUMN_VADDR, 'VirtAddr')
    retval.insert_data(0, COLUMN_PADDR, 'PhysAddr')
    retval.insert_data(0, COLUMN_FSIZE, 'FileSize')
    retval.insert_data(0, COLUMN_MSIZE, 'MemSize')
    retval.insert_data(0, COLUMN_FLAGS, 'Flags')
    retval.insert_data(0, COLUMN_ALIGN, 'Align')
    
    stats = [0] * (COLUMN_ALIGN + 1)
    for idx, phdr in enumerate(phdrs):
        stats[COLUMN_OFF] = phdr.p_offset if phdr.p_offset > stats[COLUMN_OFF] else stats[COLUMN_OFF]
        stats[COLUMN_VADDR] = phdr.p_vaddr if phdr.p_vaddr > stats[COLUMN_VADDR] else stats[COLUMN_VADDR]
        stats[COLUMN_PADDR] = phdr.p_paddr if phdr.p_paddr > stats[COLUMN_PADDR] else stats[COLUMN_PADDR]
        stats[COLUMN_FSIZE] = phdr.p_filesz if phdr.p_filesz > stats[COLUMN_FSIZE] else stats[COLUMN_FSIZE]
        stats[COLUMN_MSIZE] = phdr.p_memsz if phdr.p_memsz > stats[COLUMN_MSIZE] else stats[COLUMN_MSIZE]
        stats[COLUMN_FLAGS] = phdr.p_flags if phdr.p_flags > stats[COLUMN_FLAGS] else stats[COLUMN_FLAGS]  
        
    for idx in range(COLUMN_ALIGN + 1):
        stats[idx] = len(hex(stats[idx]).rstrip('L'))-2
        
    for idx, phdr in enumerate(phdrs):
        retval.insert_data(idx+1, COLUMN_SNO, str(idx+1))
        retval.insert_data(idx+1, COLUMN_TYPE, PT_DESCRIPTION.get(phdr.p_type, phdr.p_type))
        retval.insert_data(idx+1, COLUMN_OFF, hex_addr(phdr.p_offset, stats[COLUMN_OFF]))
        retval.insert_data(idx+1, COLUMN_VADDR, hex_addr(phdr.p_vaddr, stats[COLUMN_VADDR]))
        retval.insert_data(idx+1, COLUMN_PADDR, hex_addr(phdr.p_paddr, stats[COLUMN_PADDR]))
        retval.insert_data(idx+1, COLUMN_FSIZE, hex_addr(phdr.p_filesz, stats[COLUMN_FSIZE]))
        retval.insert_data(idx+1, COLUMN_MSIZE, hex_addr(phdr.p_memsz, stats[COLUMN_MSIZE]))
        retval.insert_data(idx+1, COLUMN_FLAGS, hex_addr(phdr.p_flags, stats[COLUMN_FLAGS]))
        retval.insert_data(idx+1, COLUMN_ALIGN, hex(phdr.p_align), justify=retval.LEFT)
    return retval.get_data()
def repr_phdrs(phdrs):
    retval = TablePrinter()

    COLUMN_SNO      = 0
    COLUMN_TYPE     = 1
    COLUMN_OFF      = 2
    COLUMN_VADDR    = 3
    COLUMN_PADDR    = 4
    COLUMN_FSIZE    = 5
    COLUMN_MSIZE    = 6
    COLUMN_FLAGS    = 7
    COLUMN_ALIGN    = 8

    retval.insert_data(0, COLUMN_SNO, 'S.No')
    retval.insert_data(0, COLUMN_TYPE, 'Type')
    retval.insert_data(0, COLUMN_OFF, 'Offset')
    retval.insert_data(0, COLUMN_VADDR, 'VirtAddr')
    retval.insert_data(0, COLUMN_PADDR, 'PhysAddr')
    retval.insert_data(0, COLUMN_FSIZE, 'FileSize')
    retval.insert_data(0, COLUMN_MSIZE, 'MemSize')
    retval.insert_data(0, COLUMN_FLAGS, 'Flags')
    retval.insert_data(0, COLUMN_ALIGN, 'Align')

    stats = [0] * (COLUMN_ALIGN + 1)
    for idx, phdr in enumerate(phdrs):
        stats[COLUMN_OFF] = phdr.p_offset if phdr.p_offset > stats[COLUMN_OFF] else stats[COLUMN_OFF]
        stats[COLUMN_VADDR] = phdr.p_vaddr if phdr.p_vaddr > stats[COLUMN_VADDR] else stats[COLUMN_VADDR]
        stats[COLUMN_PADDR] = phdr.p_paddr if phdr.p_paddr > stats[COLUMN_PADDR] else stats[COLUMN_PADDR]
        stats[COLUMN_FSIZE] = phdr.p_filesz if phdr.p_filesz > stats[COLUMN_FSIZE] else stats[COLUMN_FSIZE]
        stats[COLUMN_MSIZE] = phdr.p_memsz if phdr.p_memsz > stats[COLUMN_MSIZE] else stats[COLUMN_MSIZE]
        stats[COLUMN_FLAGS] = phdr.p_flags if phdr.p_flags > stats[COLUMN_FLAGS] else stats[COLUMN_FLAGS]

    for idx in range(COLUMN_ALIGN + 1):
        stats[idx] = len(hex(stats[idx]).rstrip('L'))-2

    for idx, phdr in enumerate(phdrs):
        retval.insert_data(idx+1, COLUMN_SNO, str(idx+1))
        retval.insert_data(idx+1, COLUMN_TYPE, PT_DESCRIPTION.get(phdr.p_type, phdr.p_type))
        retval.insert_data(idx+1, COLUMN_OFF, hex_addr(phdr.p_offset, stats[COLUMN_OFF]))
        retval.insert_data(idx+1, COLUMN_VADDR, hex_addr(phdr.p_vaddr, stats[COLUMN_VADDR]))
        retval.insert_data(idx+1, COLUMN_PADDR, hex_addr(phdr.p_paddr, stats[COLUMN_PADDR]))
        retval.insert_data(idx+1, COLUMN_FSIZE, hex_addr(phdr.p_filesz, stats[COLUMN_FSIZE]))
        retval.insert_data(idx+1, COLUMN_MSIZE, hex_addr(phdr.p_memsz, stats[COLUMN_MSIZE]))
        retval.insert_data(idx+1, COLUMN_FLAGS, hex_addr(phdr.p_flags, stats[COLUMN_FLAGS]))
        retval.insert_data(idx+1, COLUMN_ALIGN, hex(phdr.p_align), justify=retval.LEFT)
    return retval.get_data()