Hacking wbfs2fat.py

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
Help please!

I've done a mess :-(. Here is what I did:
1) Converted WBFS to FAT32 (no errors). The HD is 1TB with more or less 250 MB of free space
2) Added three more games to the WBFS folder and added one more folder to the root (names games, with 4 Gamecube games). No errors
3) Used EaseUs Partition Master to use unallocated space .... but it failed and now I can't see my partition! Now I have a partition with 200MB ... the actual data is unallocated ....

How can I recover my original WBFS data? I still have the .backup file that WBFS2FAT created but I can't use the "restore Backup" option as it failed saing "I/O exeception" ... The recovery tool programs do not see my files ....

Could I restore the file system using the .backup WBFS2FAT created? This way I could have all my original files (the data has never been actually overwritten or cancelled) and than use a WBFS File manager to move them safely.

Can you help me? I don't know how to restore the backup and I'm scared I could ruin everything .....

Thank you in advance!
 

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
Yes, it has a drive letter, but only for the 200MB partition (which is empty). The actual WBFS data is in the unallocated space ...
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
You tried to enlarge the fat32 partition, right?
In general is such things fail during operation the data is lost.

I have never used EaseUs Partition Master and no idea what it does.
Your best chance would probably be it's recovery options.

The backup wbfs2fat creates contains only the data it itself changes.
Even if you could restore it I have no idea what would happen.
No clue why you now get an IO error either.
You could try with admin rights if you haven't, but I guess EUPM messed up good.
I would abandon that direction and rather try drive recovery software.

BTW: even if everything fails the drive itself is not lost
no matter how messed up you can always zero the drive for a clean slate
(I have seen that misconception here on gbatemp)


EDIT:
what was the partition layout before and after, with as much detail as possible?
really helpful would be the exact (!) starting sector of the wbfs partition.
do you know how to handle a hex editor?
 

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
I tried to overwrite the initial sectors with hdd raw copy tool (it's similar to dd) but after that windows does not assign any letter to drive and so - can't check wbfs files ... So i reverted (i made a raw copy of the sectors) to the previous state. Yes, i can use hex editors. What should i look at? I thought that overwriting the initial sectors with wbfs2fat backup would have restored everything to previou state (i did not cancel enything) but had no luck. Probably i should restore from an offset? Thanks
 

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
UPDATE: i tried restoring sectors with dd tool. Then i could read the drive with a wbfs file manager: it saw al the games but could not retrive the correct data as all the games were listed with no ios and doing an export would reveal a fail. Can i do something else to recover the data? Thanks
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
yes restoring the initial sectors should have fixed it usually
but in your caser there is no guarantee the the partition start is in the same place as before
1. you need to find the right starting position,
2. get the right size from the backup file
3. create a partition with that parameters
4. and then dd the backup back

about 1
open the drive (not the partition) in a hex editor
search the suspected start area for a sector starting with the bytes EB 58 90 77 62 66 73 32 66 61 74 00 (in ascii: ".X.wbfs2fat.")
thats the starting sector of the partition
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
If the wbfs manager can not read the games they were overwritten (unlikey if all are affected)
or the partition is indeed in the wrong place
undo the try and try to find it

2.
to get the size open the wbfs2fat backup in the hex editor
offsets 0x04-0x07 are the wbfs's size as an big endian integer sector count
eg "22 2E 00 00" means 0x222E0000 (or 573,440,000) sectors

3.
then you need an partitioning tool that allows you to create an partition with that exact parameters without trying to create a filesystem there
I don't use windows so I can only suggest linux fdisk
(If you can not use that and do not know anything yourself I can edit the MBR for you as a last resort kind of thing)

4.
then dd the backup to it
 

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
Thank you.
Here are the values:
1) First byte of the string(EB) is at address: C900000--> Should I use this value?
Last byte of the string (00) is at address: C90000B
2) Partition Size: 74 6A 20 00
3 e 4) I don't understand one thing ... The MBR is formed by the first sectors of HD, right? If I change the MBR on the HD and then restore the dd backup to it I lose the changes ... Am I missing something?
At the moment I'm looking for a fdisk like tool for windows
Thanks for patience

UPDATE: I found the program MBRWizard. I think that I should do the following steps:
1) Delete current partition
2) Insert the partiotion. The program uses this info. Which values should I put for align and type? And size and start?
(i uploaded also the MBR, just to make sure what I'm doing)
Thanks
/Create start, size, align, type Creates a new partition on the specified disk (not currently supported on GPT). If no further options are specified a type 0x7 partition will be created in the first identified freespace. Please see the additional options for ore granular control of creating the partition.
/start= starting sector for the new partition, or 'freespace' selects the first available space on the disk
/size= size in MB of the new partition, or MAX for maximum available size
/align= alignment boundary for the new partition (1k, 2k, 4k... 128k, etc)
/type= partition type identifier
 

Attachments

  • MBR.zip
    609 bytes · Views: 169

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
yes the mbr is in the first sector (0) of the hdd
and if you would dd the backup to there you would overwrite it
the point you are missing is the the backup does not belong there
instead it belongs to the start of the newly created partition (or sector 210763776+ of the hdd)


to get the starting sector divide the starting address 0xC900000 or 210763776 by the sector size of your harddrive (512 Byte most likely, possibly 4096, others extremely rare)
the partition size is 0x746A2000 or 1953112064 sectors (about 931 GiB assuming 512B sectors)
disable alignment or at least choose the smallest possible value
type should be 0x0b but the default 0x07 should work too

confirm that the start and size were not changed by the alinment
you have to hit the start exactly, the size can be larger but not smaller

you now could try if windows can read the partition
depending on what EUPM did it could still be a valid fat32 or have all kind of damage

if you do not want to or can not read it restore the backup to the partition (not the drive)

good luck
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
did you relly fill 1tb of wii games
i can only can fill 500gb
there are some limits but 500GB is not one of them

the ones I know are:
max 32bit sector count (-> max 2TiB with the common 512B sector hdds)
max sectorsize-12 (-> 500) games
some arcane maximum on the number of games based on partition size

maybe check the hdd with wwt for details
 

ederenzi78

Well-Known Member
Newcomer
Joined
Dec 14, 2012
Messages
84
Trophies
1
Age
45
XP
1,147
Country
Italy
Thank you! It worked setting the correct partition! Now I'll be doing some checks just to make sure everything is correct.

Thank you very much!
 

gip_mad

New Member
Newbie
Joined
Dec 30, 2012
Messages
1
Trophies
0
Age
37
Website
www.mastrogippo.it
XP
51
Country
Italy
Hi, first of all thank you for the great tool. I ran into some problems with Italian titles with stupid characters:
Code:
  File "/home/gip/wbfs2fat/python/wbfs2fat.py", line 397, in mkfiles
    dname = str(tmpC.decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 3: ordinal not in range(128)
The titles are:
"SVMP01Super Mario All-Stars: Edizione per il 25° anniversario" due to the "°"
"R8AP01Poképark Wii: La Grande Avventura di Pikachu" due to the "é"
"R3LPWRLanterna Verde: L’ascesa dei Manhunters" due to the stupid ’ that is not an UTF8 '
I wrote a quick fix to replace the line 392 in the wbfs2fat.py from
Code:
dname = str(self.wbfs.games[id6][1][0x20:].decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
to:
Code:
#UTF8 stupid characters fix
            tmpC=self.wbfs.games[id6][1][0x20:]
            tmpC= tmpC.replace("°",".")
            tmpC= tmpC.replace("é","e")
            tmpC= tmpC.replace("’","'")
            #print tmpC
 
            dname = str(tmpC.decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"
            #dname = str(self.wbfs.games[id6][1][0x20:].decode("ascii")).strip(' \t\r\n\0')+" ["+id6+"]"

To people getting the error Unhandled Error: <type 'exceptions.UnicodeDecodeError'> in the GUI, just replace the lines in the file; if the error persists, uncomment the #print tmpC line and see at what title the program crashes, then add more filters as necessary.

I know it's a dirty hack, but I'm not expert in python and character encodings. This should be implemented in a more elegant way.
Regards
Mastro Gippo
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
thanks for the info I will look into it for the next version

If anyone else has that problem please post the offending chars and I will provide a quick fix if you need it

@gip_mad: could you please upload the backup file somwhere
its the easiest way for me to try a real fix
 

Cyan

GBATemp's lurking knight
Former Staff
Joined
Oct 27, 2002
Messages
23,749
Trophies
4
Age
45
Location
Engine room, learning
XP
15,646
Country
France
I never tried it yet, but French also has some special characters. I can check if my games have special chars.

Is there a mode where I can just check the data without really convert my partition?
Stopping just before the actual conversion?

Edit:
Or is the problem while renaming the files after the conversion?
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
I think I fixed the problem.
(I should probably try harder to really finish 0.9)

Some backup where it failed might still be usefull.

@Cyan
The only thing close to an simulation mode is the CLI which by default asks after the computations but before writing anything (other than the backup)
unfortunately it does not seem to work on windows curently

I removed the final renaming step in 0.9
the files are now created with the right names
which means that the error would occour before the first write
 

LoloLakitu

Shwowow Schogog
Member
Joined
Jul 26, 2012
Messages
177
Trophies
0
Location
That new rad hangout.
XP
140
Country
Canada
I keep getting error 7, so I did "wwt check" says I have 31 errors:
CHECK /dev/sde1

* Summary of WBFS Check: 31 errors found:
5 used WBFS sectors marked as free!
9 free WBFS sectors marked as used!
15 WBFS sectors are used by 2 or more discs!
2 invalid WBFS block references found!
Total: 10 discs are invalid!

Then I did "wwt repair" (assuming thats what I have to do)
And I get:
!! wwt: ERROR #17 [NO WBFS FOUND] in AnalyzePartitions() @ src/wbfs-interface.c#
447
!! no WBFS partitions found -> abort

Using 320GB WD My Passport
 

PsyBlade

Snake Charmer
OP
Member
Joined
Jul 30, 2009
Messages
2,204
Trophies
0
Location
Sol III
XP
458
Country
Gambia, The
try specifieing the drive to repair
"wwt repair /dev/sde1"

I'm not that experienced wit wwt
but it also has a help function ("wwt help repair"), gbatemp thread and web page

edit:
wbfs2fat error 7 is "permission denied"
that means that it could not open the drive
try running it with admin rights and close all other wbfs related programs

while you should try to fix the errors with wwt before
it could benefit from the same hints
 

LoloLakitu

Shwowow Schogog
Member
Joined
Jul 26, 2012
Messages
177
Trophies
0
Location
That new rad hangout.
XP
140
Country
Canada
try specifieing the drive to repair
"wwt repair /dev/sde1"

I'm not that experienced wit wwt
but it also has a help function ("wwt help repair"), gbatemp thread and web page

edit:
wbfs2fat error 7 is "permission denied"
that means that it could not open the drive
try running it with admin rights and close all other wbfs related programs

while you should try to fix the errors with wwt before
it could benefit from the same hints

Oh sorry, I meant I got error 6 every time.
And it says in wbfs2fat "wbfs is corrupted: Blocks used multiple times"
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • K3Nv2 @ K3Nv2:
    @Sicklyboy, $150 isn't that bad for a jtag slim on ebay
  • Veho @ Veho:
    I only wish it was actually playable.
  • Veho @ Veho:
    There's a guy on the Tube of You that makes playable mechanical arcade games out of Lego. This could work on the same principle.
  • Veho @ Veho:
    Just a couple of guys taking their manatee out for some fresh air, why you have to molest them?
  • Veho @ Veho:
    Stupid Chinese shop switched their shipping company and this one is slooooooow.
  • LeoTCK @ LeoTCK:
    STOP BUYING CHINESE CRAP THEN
  • LeoTCK @ LeoTCK:
    SUPPORT LOCAL PRODUCTS, MAKE REVOLUTION
  • LeoTCK @ LeoTCK:
    THEY KEEP REMOVING LOCAL SHIt AND REPLACING WItH INFERIOR CHINESE CRAP
  • LeoTCK @ LeoTCK:
    THATS WHY MY PARTNER CANT GET A GOOTWEAR HIS SIZE ANYMORE
  • LeoTCK @ LeoTCK:
    HE HAS BIG FOOT AND BIG DUCK
  • LeoTCK @ LeoTCK:
    d*ck i mean*
  • LeoTCK @ LeoTCK:
    lol
  • Veho @ Veho:
    Mkay.
  • Veho @ Veho:
    I just ordered another package from China just to spite you.
  • SylverReZ @ SylverReZ:
    Communism lol
  • SylverReZ @ SylverReZ:
    OUR products
  • The Real Jdbye @ The Real Jdbye:
    @LeoTCK actually good quality products are dying out because they can't compete with dropshipped chinese crap
    +2
  • BakerMan @ BakerMan:
    @LeoTCK is your partner the sascrotch or smth?
  • Xdqwerty @ Xdqwerty:
    Good morning
  • Xdqwerty @ Xdqwerty:
    Out of nowhere I got several scars on my forearm and part of my arm and it really itches.
  • AdRoz78 @ AdRoz78:
    Hey, I bought a modchip today and it says "New 2040plus" in the top left corner. Is this a legit chip or was I scammed?
    AdRoz78 @ AdRoz78: Hey, I bought a modchip today and it says "New 2040plus" in the top left corner. Is this a legit...