Hacking wwt+wit: Wiimms WBFS+ISO Tools

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
wit is back again.

I have some code in the hidden part of the repository to implement new features. Years ago I planned a feature, to patch a Wii image by a Riivolution XML + files. Because of the the NEWER SMBW activities in the last days, I have completed the DOL patching feature and extended the DOL dump function. I don't know, if I'll implement more.

wit DUMP file.dol

This is an very old feature. It dump the section table of dol files, for example NSMB:
Code:
# wit dump pool/nsmb/main.dol

Dump of file pool/nsmb/main.dol

  Real path:         .../nsmb/main.dol
  File size:            354b00/hex =    3492608 = 3411 KiB
  File type:         DOL

  Memory map of DOL file:

           unused :  off(beg) ..  off(end) :      size : section
     -----------------------------------------------------------------------
                  :         0 ..       100 :       100 : DOL header
                  :       100 ..      27c0 :      26c0 : text section #0
                  :      27c0 ..    2e9d20 :    2e7560 : text section #1
                  :    2e9d20 ..    2e9d80 :        60 : data section #0
                  :    2e9d80 ..    2e9de0 :        60 : data section #1
                  :    2e9de0 ..    2ea0c0 :       2e0 : data section #2
                  :    2ea0c0 ..    2ea0e0 :        20 : data section #3
                  :    2ea0e0 ..    2fa7a0 :     106c0 : data section #4
                  :    2fa7a0 ..    34da80 :     532e0 : data section #5
                  :    34da80 ..    34ffa0 :      2520 : data section #6
                  :    34ffa0 ..    354b00 :      4b60 : data section #7
                  :    354b00 ..    354b00 :         0 : --- end of file ---

  Memory map of DOL image:

           unused :  off(beg) ..  off(end) :      size : section
     -------------------------------------------------------------------
     .!           :  80004000 ..  800066c0 :      26c0 : text section #0
     !.           :  80004050 ..  80004050 :         0 : entry point
                  :  800066c0 ..  80006720 :        60 : data section #0
                  :  80006720 ..  80006780 :        60 : data section #1
                  :  80006780 ..  802edce0 :    2e7560 : text section #1
                  :  802edce0 ..  802edfc0 :       2e0 : data section #2
                  :  802edfc0 ..  802edfe0 :        20 : data section #3
                  :  802edfe0 ..  802fe6a0 :     106c0 : data section #4
                  :  802fe6a0 ..  80351980 :     532e0 : data section #5
     .!           :  80351980 ..  8042ff1c :     de59c : bss section
     !.           :  80427980 ..  80429ea0 :      2520 : data section #6
                  :  8042b360 ..  8042fec0 :      4b60 : data section #7

If adding option --long (short: -l), a third table with a delta value is printed. This delta helps to translate a virtual memory address to a file offset for hex editing.
Code:
# wit dump pool/nsmb/main.dol --long
....
 
  Delta between file offset and virtual address:

           unused :  off(beg) ..  off(end) :      size :    delta : section
     ----------------------------------------------------------------------
                  :  80004000 ..  800066c0 :      26c0 : 80003f00 : text #0
                  :  800066c0 ..  80006720 :        60 : 7fd1c9a0 : data #0
                  :  80006720 ..  80006780 :        60 : 7fd1c9a0 : data #1
                  :  80006780 ..  802edce0 :    2e7560 : 80003fc0 : text #1
                  :  802edce0 ..  802edfc0 :       2e0 : 80003f00 : data #2
                  :  802edfc0 ..  802edfe0 :        20 : 80003f00 : data #3
                  :  802edfe0 ..  802fe6a0 :     106c0 : 80003f00 : data #4
                  :  802fe6a0 ..  80351980 :     532e0 : 80003f00 : data #5
            d6000 :  80427980 ..  80429ea0 :      2520 : 800d9f00 : data #6
             14c0 :  8042b360 ..  8042fec0 :      4b60 : 800db3c0 : data #7


wit DOLPATCH file.dol

This new command allow to patch a DOL file. The syntax is:
Code:
# wit help dolpatch --width 75

wit DOLPATCH : Patch a dol file. If 'riiv_xml_file' is a single point
               ('.'), it is ignored. Otherwise a Riivolution XML file is
               expected. It is scanned for '<memory ../>' tags as patch
               rules, all others are ignored.
                 Each sub-command is a simple 'offset=hexstring#cond'
               statement and 'hexstring' are any number of hex digits. The
               optional '#cond' defines a hex string condition like the
               'original=' attribute in the XML file. The patch is only
               applied, if the condition match the source. Bytes of the
               hex strings can be separated by spaces or points.

Syntax: wit DOLPATCH dolfile riiv_xml_file [sub_commands]...

Options:

  -t --test       Run in test mode, modify nothing.
                  >>> USE THIS OPTION IF UNSURE! <<<
  -d --dest path  Define a destination path (directory/file). If not set,
                  the source file is repalced.
  -D --DEST path  Like --dest, but create the directory path
                  automatically.

At the moment the command is very verbose, and option --quiet has no effect.

Example for NEWER SMBW:
Code:
# wit dolpat nsmb/main.dol -d nsmb/res.dol nsmb/NewerSMBW.xml
+Patched:         [D4] addr 802f148c+07, offset  2ed58c: 77 69 69 6d 6a 32 64 -> 4e 65 72 53 4d 42 57
-Original differ: [D4] addr 802f118c+07, offset  2ed28c: 00 00 00 00 80 31 65
-Original differ: [D4] addr 802f0fac+07, offset  2ed0ac: 00 00 00 2a 00 00 00
+Patched:         [D5] addr 80328478+04, offset  324578: 80 15 bc 60 -> 80 00 18 00
-Original differ: [D5] addr 80328130+04, offset  324230: 80 15 a5 b0
-Original differ: [D5] addr 80327e98+04, offset  323f98: 72 75 5f 30
+Patched:         [T1] addr 800e4a84+04, offset   e0ac4: 3c 60 01 20 -> 3c 60 01 40
-Original differ: [T1] addr 800e4994+04, offset   e09d4: 80 84 00 4c
-Original differ: [T1] addr 800e4914+04, offset   e0954: 00 00 00 00
+Patched:         [T1] addr 800b64ec+04, offset   b252c: 3c 80 00 30 -> 3c 80 00 32
-Original differ: [T1] addr 800b649c+04, offset   b24dc: 4e 80 00 20
-Original differ: [T1] addr 800b641c+04, offset   b245c: 83 e3 00 08
+Patched:         [T1] addr 801b0204+04, offset  1ac244: 54 00 ff fe -> 38 00 00 00
-Original differ: [T1] addr 801b00c4+04, offset  1ac104: 39 46 00 12
-Original differ: [T1] addr 801afed4+04, offset  1abf14: 83 a1 00 44
+Patched:         [T1] addr 8015d850+04, offset  159890: 38 60 00 00 -> 4e 80 00 20
-Original differ: [T1] addr 8015d710+04, offset  159750: 40 82 00 40
-Original differ: [T1] addr 8015d520+04, offset  159560: 81 9e 00 74
+Patched:         [T1] addr 800e4e84+04, offset   e0ec4: 38 63 33 0c -> 38 60 00 00
-Original differ: [T1] addr 800e4d70+04, offset   e0db0: 90 7f 00 4c
-Original differ: [T1] addr 800e4cf0+04, offset   e0d30: 41 82 00 1c
!Can't patch: Range outside dol: addr 80001800+968
* Save patched DOL to: nsmb/res.dol
The command line accepts also patch statements.

I have committed the current version to the beta repository:
* http://opensvn.wiimm.de/wii/branches/public/wiimms-iso-tools/
 

Ayatus

Well-Known Member
Newcomer
Joined
Apr 4, 2012
Messages
87
Trophies
1
Age
47
XP
276
Country
France
Great command line tools but missing libpng14.so for SZS Tools on Kubuntu.
I have found it in a rpm package.:wtf:
 

Garfunkiel

Active Member
Newcomer
Joined
Mar 11, 2010
Messages
28
Trophies
1
XP
518
Country
United States
@Wiimm: Why is there a "!Can't patch: Range outside dol: addr 80001800+968" in the output? Does the patched dol for sure work without it? Also, does the dolpatch function handle <memory> tags with valuefile attributes?

Anyway, thanks for developing this feature. Definitely more convenient than hex editing the files by hand.
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
@Wiimm: Why is there a "!Can't patch: Range outside dol: addr 80001800+968" in the output? Does the patched dol for sure work without it? Also, does the dolpatch function handle <memory> tags with valuefile attributes?

Anyway, thanks for developing this feature. Definitely more convenient than hex editing the files by hand.

The message is because of this:
Code:
    <memory offset="0x80001800" valuefile="Loader.bin" />
The offset is outside the DOL address range (its before the DOL). For the NEWER patch, DMM has inserted a new text section and moved the loader to an other address. And yes, valuefile is supported.
 

Garfunkiel

Active Member
Newcomer
Joined
Mar 11, 2010
Messages
28
Trophies
1
XP
518
Country
United States
I don't suppose there could be an automated way to make that change generically, based on the xml? Either way, this works great for other Riivolution mods that don't add their own loaders, so thanks!
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
wiimms-tools.png


WIT: Wiimms ISO Tools v2.21a - 2013-06-15
A command line ISO+WBFS tool set for various os.

WIT (Wiimms ISO Tools) is a set of command line tools to manipulate Wii ISO images and WBFS containers. The two main tools are called wit (Wiimms ISO Tool) and wwt (Wiimms WBFS Tool, the WBFS manager).

Feature overview:
Visit http://wit.wiimm.de/features.html for more details.

Download of the current version:

There are also some GUI available:

Highlights of this release:
  • I had stopped the WIT development, but then NEWER SMBW appeared!

    Years ago I planed to use a Riivolution setup to patch a Wii image. So I implemented a first DOL support. I had also implemented first steps to patch a DOL; this code was hidden in a private area of my SVN repository.

    And with NEWER SMBW there was a need to activate the code. Therefore I have implemented the new command DOLPATCH together with some more little extensions.

Change log:

Code:
wit v2.21a r4489 - 2013-06-15

 - The default image format switched from WDF to WBFS. This is only relevant,
   if no image type is specified by source, option or file extension, for
   example for the command "wwt EXTRACT".
 - wit DUMP --long: If dumping a DOL file, a third table with delta values
   between the virtual address and the file offset is printed.
 - New command: wit DOLPATCH: Patch a DOL file by reading a Riivolution XML
   file and scanning all memory tags.
   -> Read http://wit.wiimm.de/cmd/wit/dolpatch for details.
 - If extracting an image, the file 'setup.txt' contains now a new parameter:
   "image-type = TYPE". It shows the image type of the source image.
   If cretaing an image and file 'setup.txt' contains this paramater with a
   valid image type, this image type is used as default for the new created
   image. The default is superseded by format options and file extensions.
     This feature is dedicated to patching scripts. If an original image is
   extracted with "wit extract -1n ANYID6 . WORKDIR --psel data" and then
   patched, an image with identical image type as the original can be created
   by the command: wit copy WORKDIR %x --id NEWID6 --name "new title of game"
 - For easier script/batch support, the files "setup.sh" and "setup.bat" are
   created for extracted images. They contain similar info as "setup.txt", but
   can be directly included by ". ./PATH/setup.sh" or  "CALL ./PATH/setup.bat"
   to get the settings as script variables.

The source is published under the license of GPL2. Checkout the sources directly from the SVN repository or browse the source. Visit http://wit.wiimm.de/ for more information.
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
I have tested the DOLPATCH command only under linux/64 bit. And now a bug on 32 bit systems were found.
Code:
wit v2.21b r4492 - 2013-06-15

 - Bug fix: wit DOLPATCH: Reading 'offset' failed on 32 bit systems.
The bug fix update to v2.21b is online!
 
  • Like
Reactions: tmv_josue

markehmus

Well-Known Member
Member
Joined
Jul 26, 2008
Messages
1,521
Trophies
0
Age
112
Location
in the GAME
XP
1,279
Country
Canada
if you find time to look , whats done wrong here using
wit DOLPATCH dolfile riiv_xml_file
Code:
C:\Users\Desktop\wit-v2.21a-r4489-cygwin>C:\Users\Desktop\wit-v2.21a-r
4489-cygwin\Cannon_Super_Mario_Bros._Wii_v1.1\wit\wit.exe dolpatch C:\Users
\Desktop\wit-v2.21a-r4489-cygwin\Cannon_Super_Mario_Bros._Wii_v1.1\main.dol C:\U
sers\Desktop\wit-v2.21a-r4489-cygwin\Cannon_Super_Mario_Bros._Wii_v1.1\riiv
olution\CannonE.xml
cygwin warning:
  MS-DOS style path detected: C:\Users\Desktop\wit-v2.21a-r4489-cygwin\Cann
on_Super_Mario_Bros._Wii_v1.1\main.dol
  Preferred POSIX equivalent is: /main.dol
  CYGWIN environment variable option "nodosfilewarning" turns off this warning.
  Consult the user's guide for more details about POSIX paths:
    http://cygwin.com/cygwin-ug-net/using.html#using-pathnames
! wit: Missing '=':
!      C:\Users\Desktop\wit-v2.21a-r4489-cygwin\Cannon_Super_Mario_Bros._W
!      ii_v1.1\riivolution\CannonE.xml
* DOL not modified: C:\Users\Desktop\wit-v2.21a-r4489-cygwin\Cannon_Super_M
ario_Bros._Wii_v1.1\main.dol
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
The xml file must be prefixed by XML= to distinguish it from other commands.
xml=C:/path/to/CannonE.xml

And try to use relative pathes. YOu can use them if you "cd" to the working directory.
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
One point for clearness:
My tool can neither modify the loader.bin like DMM has made it nor create a new text section for the loader. This is special to NEWER SMBW and must be done by hand and knowledge.
 

markehmus

Well-Known Member
Member
Joined
Jul 26, 2008
Messages
1,521
Trophies
0
Age
112
Location
in the GAME
XP
1,279
Country
Canada
guess i can try it,
the loader offset looks the same but it looks like the other offsets are different

Are the patches also the same?
Then use the main.dol patched by damysteryman.


Code:
<?xml version="1.0"?>
-<wiidisc log="true" root="/NewerSMBW" shiftfiles="true" version="1">-<id game="SMN"><region type="P"/><region type="E"/><region type="J"/></id>-<options>+<section name="Newer SMBW">--</options>-<patch id="newercore"><savegame clone="false" external="/save/{$__gameid}{$__region}"/><folder external="Tilesets" create="true" disc="/Stage/Texture"/><folder external="TitleReplay" create="true" disc="/Replay/title"/><folder external="BGs" create="true" disc="/Object"/><folder external="SpriteTex" create="true" disc="/Object"/><folder external="Layouts" create="true" disc="/Layout"/><folder external="Music" create="true" disc="/Sound/new"/><folder external="Music/sfx" create="true" disc="/Sound/new/sfx"/><folder external="Music/stream" create="true" disc="/Sound/stream"/><folder external="Music/rsar" disc="/Sound"/><folder external="Font" disc="/EU/EngEU/Font"/><folder external="Font" disc="/EU/FraEU/Font"/><folder external="Font" disc="/EU/SpaEU/Font"/><folder external="Font" disc="/EU/ItaEU/Font"/><folder external="Font" disc="/US/EngUS/Font"/><folder external="Font" disc="/US/FraUS/Font"/><folder external="Font" disc="/US/SpaUS/Font"/><folder external="Font" disc="/JP/Font"/><folder external="Message" disc="/EU/EngEU/Message"/><folder external="Message" disc="/EU/FraEU/Message"/><folder external="Message" disc="/EU/SpaEU/Message"/><folder external="Message" disc="/EU/ItaEU/Message"/><folder external="Message" disc="/US/EngUS/Message"/><folder external="Message" disc="/US/FraUS/Message"/><folder external="Message" disc="/US/SpaUS/Message"/><folder external="Message" disc="/JP/Message"/><folder external="NewerRes" create="true" disc="/NewerRes"/>
<!-- <folder external="CS" disc="/CS" create="true" /> -->
<folder external="LevelSamples" create="true" disc="/LevelSamples"/><folder external="Others"/><folder external="Others{$__region}"/><folder external="Maps" create="true" disc="/Maps"/><folder external="Maps/Texture" create="true" disc="/Maps"/><folder external="Stages" create="true" disc="/Stage"/>
<!-- Save name change -->
 
<!--PAL-->
<memory original="7769696D6A3264" value="4E6572534d4257" offset="0x802F148C"/>
<!--NTSC-->
<memory original="7769696D6A3264" value="4E6572534d4257" offset="0x802F118C"/>
<!--JPN-->
<memory original="7769696D6A3264" value="4E6572534d4257" offset="0x802F0FAC"/>
<!-- Inject Newer loader -->
 
<!--PAL-->
<memory original="8015BC60" value="80001800" offset="0x80328478"/>
<!--NTSC-->
<memory original="8015BB20" value="80001800" offset="0x80328130"/>
<!--JPN-->
<memory original="8015B930" value="80001800" offset="0x80327E98"/>
<!-- Expand ArchiveHeap -->
 
<!--PAL-->
<memory original="3C600120" value="3C600140" offset="0x800E4A84"/>
<!--NTSC-->
<memory original="3C600120" value="3C600140" offset="0x800E4994"/>
<!--JPN-->
<memory original="3C600120" value="3C600140" offset="0x800E4914"/>
<!-- Expand 2DHeap -->
 
<!--PAL-->
<memory original="3C800030" value="3C800032" offset="0x800B64EC"/>
<!--NTSC-->
<memory original="3C800030" value="3C800032" offset="0x800B649C"/>
<!--JPN-->
<memory original="3C800030" value="3C800032" offset="0x800B641C"/>
<!-- Force non-Japanese font -->
 
<!--PAL-->
<memory original="5400FFFE" value="38000000" offset="0x801B0204"/>
<!--NTSC-->
<memory original="5400FFFE" value="38000000" offset="0x801B00C4"/>
<!--JPN-->
<memory original="5400FFFE" value="38000000" offset="0x801AFED4"/>
<!-- Title screen fixes -->
 
<!--PAL-->
<memory original="38600000" value="4E800020" offset="0x8015D850"/>
<!--NTSC-->
<memory original="38600000" value="4E800020" offset="0x8015D710"/>
<!--JPN-->
<memory original="38600000" value="4E800020" offset="0x8015D520"/>
<!-- Disable debug key sequence -->
 
<!--PAL-->
<memory original="3863330C" value="38600000" offset="0x800E4E84"/>
<!--NTSC-->
<memory original="3863300C" value="38600000" offset="0x800E4D70"/>
<!--JPN-->
<memory original="38632E2C" value="38600000" offset="0x800E4CF0"/>
<!-- Common -->
<memory offset="0x80001800" valuefile="Loader.bin"/></patch></wiidisc>

Cannon(ntsc)
Code:
<?xml version="1.0"?>
-<wiidisc log="true" shiftfiles="true" version="1">-<id game="SMN"><region type="E"/></id>-<options>-<section name="New Mario Bros Cannon">-<option name="New Mario Bros Cannon" default="1" id="Cannon">-<choice name="Enabled"><patch id="Cannon"/></choice></option></section></options>-<patch id="Cannon" root="/Cannon"><savegame clone="false" external="/Cannon/save/{$__gameid}{$__region}"/><folder external="Stage/Texture" create="true" disc="/Stage/Texture/"/><folder external="NewerRes" create="true" disc="/NewerRes/"/><folder external="Stage" create="true" disc="/Stage/"/><folder external="Lang"/><folder external="Stage"/><folder external="MessageEN"/><folder external="Sound/stream/"/><folder external="Layout/textures/"/><folder external="Layout/sequenceBG/"/><folder external="Layout/preGame/"/><folder external="Layout/staffCredit/"/><folder external="Sound"/><folder external="WorldMap"/><folder external="Env"/><folder external="MovieDemo"/><folder external="Object" create="true" disc="/Object/"/><folder external="OpeningE"/><memory original="3C600120" value="3C600140" offset="0x800E4914"/><memory original="3C600120" value="3C600140" offset="0x800E4994"/><memory original="3C600120" value="3C600140" offset="0x800E4A84"/><memory original="8015BB20" value="80001800" offset="0x80328130"/><memory original="8015BC60" value="80001800" offset="0x80328478"/><memory offset="0x80001800" valuefile="Loader.bin"/></patch></wiidisc>
 

Wiimm

Developer
OP
Member
Joined
Aug 11, 2009
Messages
2,292
Trophies
1
Location
Germany
Website
wiimmfi.de
XP
1,519
Country
Germany
wiimms-tools.png


WIT: Wiimms ISO Tools v2.22a - 2013-06-22
A command line ISO+WBFS tool set for various os.

WIT (Wiimms ISO Tools) is a set of command line tools to manipulate Wii ISO images and WBFS containers. The two main tools are called wit (Wiimms ISO Tool) and wwt (Wiimms WBFS Tool, the WBFS manager).

Feature overview:
Visit http://wit.wiimm.de/features.htmlfor more details.

Download of the current version:
There are also some GUI available:
Highlights of this release:
  • Command wit DOLPATCH is now able to create new sections.
    .
  • If TICKET and TMD ID differ, the game freeze after loading. So it make sense, to change both with only one option: --tt-id
    .
Change log:

Code:
wit v2.22a r4516 - 2013-06-22
 
- Command "wit DOLPATCH" accepts now more commands and is able to create new
  TEXT and DATA sections.
  -> Read http://wit.wiimm.de/cmd/wit/dolpatch for details.
- New option: --tt-id=ID: This is a short cut for `--ticket=ID --tmd=ID´.
  If TICKET and TMD differ, the game will freeze after loading. So it make
  sense to change only TICKET and TMD IDs together.
- Bug fix, if using "wit COPY --name discname" and the destination is %X or
  similar: The new discname is now used to create the filename.

The source is published under the license of GPL2. Checkout the sources directly from the SVN repository or browse the source. Visit http://wit.wiimm.de/ for more information.
 
  • Like
Reactions: tmv_josue

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    I @ I-need-help-with-wup-wiiu: i have an issue with loading games on usb with usbloadergx on vwii. Is there anyone that can...