Guide#

Installation#

This package can be installed on Linux, macOS, and Windows platforms for recent (3.8+) versions of Python. The latest release can be installed from PyPI using pip:

pip install pyxbe

The very latest development version can be installed from GitHub via:

pip install --user https://github.com/mborgerson/pyxbe/archive/refs/heads/master.zip

Usage Example#

In [1]: from xbe import Xbe

In [2]: xbe = Xbe.from_file('../tests/xbefiles/triangle.xbe')

In [3]: # Get basic info about the XBE
   ...: xbe.title_name
   ...: 
Out[3]: 'triangle'

In [4]: hex(xbe.entry_addr)
Out[4]: '0x36720'

In [5]: # Get detailed info from XBE data structures
   ...: xbe.header
   ...: 
Out[5]: 
magic:                       0x48454258
signature:                   
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
base_addr:                   0x10000
headers_size:                0xbc4
image_size:                  0x29eb8
image_header_size:           0x178
timestamp:                   0x5e0fcac9
certificate_addr:            0x10178
section_count:               0x7
section_headers_addr:        0x10348
init_flags:                  <InitFlags.LIMIT64MB|MOUNT_UTILITY_DRIVE: 5>
entry_addr:                  0xa8ff308b
tls_addr:                    0x12218
pe_stack_commit:             0x10000
pe_heap_reserve:             0x100000
pe_heap_commit:              0x1000
pe_base_addr:                0x10000
pe_image_size:               0x2a000
pe_checksum:                 0x0
pe_timestamp:                0x0
debug_pathname_addr:         0x1051b
debug_filename_addr:         0x1051b
debug_unicode_filename_addr: 0x1051b
kern_thunk_addr:             0x5b6ec19a
import_dir_addr:             0x0
lib_versions_count:          0x1
lib_versions_addr:           0x1050b
kern_lib_version_addr:       0x0
xapi_lib_version_addr:       0x0
logo_addr:                   0x10520
logo_size:                   0x17b

In [6]: # List sections
   ...: xbe.sections
   ...: 
Out[6]: 
{'.rdata': <XbeSection name='.rdata' vaddr=0x11000 vsize=0x3000>,
 '.bss': <XbeSection name='.bss' vaddr=0x14000 vsize=0x3000>,
 '.data': <XbeSection name='.data' vaddr=0x17000 vsize=0x2000>,
 '.text': <XbeSection name='.text' vaddr=0x19000 vsize=0x1e000>,
 '.tls': <XbeSection name='.tls' vaddr=0x37000 vsize=0x1000>,
 '.idata': <XbeSection name='.idata' vaddr=0x38000 vsize=0x1000>,
 '.reloc': <XbeSection name='.reloc' vaddr=0x39000 vsize=0xeb8>}

In [7]: # Get detailed section info
   ...: xbe.sections['.text'].header
   ...: 
Out[7]: 
flags:                           <Flags.EXECUTABLE|PRELOAD: 6>
virtual_addr:                    0x19000
virtual_size:                    0x1e000
raw_addr:                        0x7000
raw_size:                        0x1e000
section_name_addr:               0x104f2
section_name_ref_count:          0x0
head_shared_page_ref_count_addr: 0x104d6
tail_shared_page_ref_count_addr: 0x104d8
digest:                          
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
  00 00 00 00

In [8]: # Get section data
   ...: len(xbe.sections['.text'].data)
   ...: 
Out[8]: 122880

In [9]: # Get cert info
   ...: xbe.cert
   ...: 
Out[9]: 
size:               0x1d0
timestamp:          0x5e0fcac9
title_id:           0xffff0002
title_name:         
  0074 0072 0069 0061 006e 0067 006c 0065 
  0000 0000 0000 0000 0000 0000 0000 0000 
  0000 0000 0000 0000 0000 0000 0000 0000 
  0000 0000 0000 0000 0000 0000 0000 0000 
  0000 0000 0000 0000 0000 0000 0000 0000 
title_alt_ids:      
  00000000 00000000 00000000 00000000 
  00000000 00000000 00000000 00000000 
  00000000 00000000 00000000 00000000 
  00000000 00000000 00000000 00000000 
allowed_media:      <AllowedMediaTypes.NONSECURE_MODE|NONSECURE_HARD_DISK|MEDIA_BOARD|DVD_CD|HARD_DISK: 3221225989>
game_region:        <GameRegions.MANUFACTURING|RESTOFWORLD|JAPAN|NA: 2147483655>
ratings:            0xffffffff
disc_num:           0x0
version:            0x0
lan_key:            
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
signature_key:      
  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
alt_signature_keys: ?

Command Line Usage Example#

To dump out various details about the XBE file, you can invoke the module:

python3 -m xbe default.xbe

To extract embedded title and save images in the XBE:

python3 -m xbe --extract-images default.xbe

To convert .xbx images to BMP:

python3 -m xbe --xbx-to-bmp *.xbx