antangelo / xdvdfs

Original Xbox DVD Filesystem library and management tool
https://xiso.antangelo.com/
MIT License
73 stars 8 forks source link

Feature Request: Unpack single file from an iso. #54

Closed rizaumami closed 9 months ago

rizaumami commented 1 year ago

I need to get the game's launcher (default.xbe, game.xbe, etc) from an iso. Until now, I use xbfuse to mount the iso and then get the launcher. Would be handy if xdvdfs can extract/unpack file from an iso only by providing the file's name.

If not, probably by give an extra column in info for displaying offset where file located so we can "dump" it using dd or similar tools..

Thanx.

rizaumami commented 1 year ago

Is this similar to what I need?

xdvdfs info CoolGame.iso /default.xbe

EDIT: Have difficulty to convert sector into offset so I can dump the file using dd.

This is example for The Warriors.

Using xbfuse:

iza@sid:~$ xbfuse '/mnt/data/tests/Warriors, The (USA).iso' /home/iza/XBMount/ -o use_ino
iza@sid:~$ stat --printf='offset: %i\nsize: %s\n' /tmp/test/default.xbe
offset: 3912871936
size: 4636672

And then extract default.xbe using dd:

iza@sid:~$ dd if='/mnt/data/tests/Warriors, The (USA).iso'  of=/tmp/default.xbe skip=3912871936 count=4636672 iflag=skip_bytes,count_bytes

The default.xbe is valid and its hash matched.

Using xdvdfs:

iza@sid:~$ xdvdfs info '/mnt/data/tests/Warriors, The (USA).iso'
Valid:               true
Creation time:       127722764129460000
Root Entry:          Sector 1715631 (2048 bytes)
iza@sid:~$ xdvdfs info '/mnt/data/tests/Warriors, The (USA).iso' /default.xbe
Name:                default.xbe
Left Child Offset:   52 bytes
Right Child Offset:  92 bytes
Data Location:       Sector 1712438 (4636672 bytes)
Attributes:          Normal

Unable to successfully dump the default.xbe using these info.

antangelo commented 1 year ago

The sector information reported by xdvdfs info does not include the offset of the game partition in a redump (that is, it assumes the xdvdfs partition always starts at sector 0). If you want to convert this into an offset into the file, you can multiply the sector number by 2048 and add in the offset (if applicable). The other number in the data location line is the file size in bytes.

Either way, we should support extracting single files through the unpack command directly.

rizaumami commented 1 year ago

The sector information reported by xdvdfs info does not include the offset of the game partition in a redump (that is, it assumes the xdvdfs partition always starts at sector 0).

Ahh, so that's why I was unable to correctly dump the file.

According to xemu docs, this video partition is 387 MB or 405798912 Bytes (1024*1024*387).

iza@sid:~$ xdvdfs info '/mnt/data/tests/Warriors, The (USA).iso' /default.xbe
Name:                default.xbe
Left Child Offset:   52 bytes
Right Child Offset:  92 bytes
Data Location:       Sector 1712438 (4636672 bytes)
Attributes:          Normal
iza@sid:~$ echo $(((1024*1024*387)+(1712438*2048)))
3912871936

Now we get 3912871936, the same number printed by xbfuse as the offset.

Thank you. I'll leave this issue open as feature request, or you can just close it as I've resolved the problem.