1 (edited by V. 2013-01-11 16:16:38)

Howdy again,

This is something initially thought up by Jackal and (I think) iR0b0t.
What it does is trying to fix a mode 2 form 2 sector, which can be found on CD-ROM XA discs, like PSX and CD-i Discs.
These sectors have no ECC code, only a EDC code to check the validity of the sector.
We can try to fix these sectors by brute forcing all the data bytes until we find a match.
That is basically what this program is used for.

It can only fix a single byte for 2 reasons:
1. finding 2 random errors on 2 random places takes 6 days, even with the fast crc routines I am using.
2. trying to fix more then 1 byte means that the possible fixes increase to a level where it is just a random guess as to which is the right fix.

Although, if the demand is there, an option to fix 2 consecutive bytes could be added.
The speed hit then will only be x256 (around 2 minutes on my workstation) and false positives would also be more manageable.

The readme:

What:
 This is a not yet idiotproof version of cdxafix.
 It is to be used to try to fix Mode 2 Form 2 sectors in Playstation 1 or CD-i CD images.

How:
 cdxafix <file> <sector>

 File is a PSX, CD-i or other CDXA image file.
 Sector is the sector to try to fix.
 You get the sector number from CDmage or another CD Image checking utility.

 After (or rather, if) cdxafix finds one or more fixes, then you can use applyfix to apply them.

 applyfix <file> <sector> <offset> <new data>

 First off, there is no undo!
 Make a backup first, or re-apply the original data you got from cdxafix (2nd number).

 Offset is the first number you got from cdxafix, new data is the 3th (in hex).

 Try the fix with the lowest number of bits first, or, if it is availiable, an 8 bit fix.
 After fixing, check the image as a whole with redump to see if you get a match.
 If you don't, then:
 - you have a different pressing.
 - and/or there might be other, more subtle errors.
 - and/or the error is part of the image.
 - and/or redump has faulthy (probably not validated yet) information.
 (yes, all 4 could apply too).

 A special case is when cdxafix finds a mismatch in the subheader and it's copy.
 Then you have to apply all the fixes that are in the list (cdxafix will tell you when this happens).

Why:
 Mode 2 Form 2 sectors are only protected by an EDC block and not by ECC.
 This means that data errors can not be fixed, only found by CRC checks.
 What cdxafix does is try to bruteforce every databyte to find some dataset which matches the EDC.

Warning:
 This software is not yet idiotproof!
 - It does not check arguments for validity yet.

 Also, do NOT, I repeat, DO NOT use this to 'fix' sectors where you have no other means to
 check validity of the data (such as a redump.org entry).
 ESPECIALLY, do NOT use this to actually 'fix' sectors before submitting a result to redump!
 Some CD's deliberately introduce errors in EDC as part of the on disc data,
 for instance for copy protection or other means.
 This also goes for validity / confirmation entries to redump!
 ALWAYS use the proper redump guides to dump images and NEVER rely on fixes like these!

Compiling:
 Use "make" on any linux/unix/bsd console nearby, or if you must, an msys or cygwin environment.
 You need to use a relatively recent gcc (4.5.0+ ish I guess).
 On windows, if you have a 64bit MinGW, you can use "make 64=1" to build a (much faster) 64bit version.

 This software uses crcutil-1.0 for providing fast crc calculations.
 crcutil is made by Andrew Kadatch and Bob Jenkins and can be found on http://code.google.com/p/crcutil/
 Do not contact them for support on findcrcs.
 The Makefile will try to pull in version 1.0 through wget if it is not supplied yet.

Contact:
 At the moment, see the redump.org forum thread where you got this.

-V.

And an example run:

~/cdxafix-0.1$ cdxafix kidclown2.bin 24908
Possible fixes:
771  45 -> 44  (1 bit fix)
1026  0c -> 5d  (3 bit fix)
~/cdxafix-0.1$ applyfix kidclown2.bin 24908 771 44
45 -> 44
~/cdxafix-0.1$ cdxafix kidclown2.bin 24908
Sector ECD matches sector data. No fix required.
~/cdxafix-0.1$ 

Standard disclaimer:
I write my tools mainly for myself to use in a specific way.
If however someone has some issues using this, or has some suggestions, i MIGHT be able to change, fix or add things, but only if time and effort are permitting (which is not usually the case).

ps.
--> READ THE SECOND PART OF THE WARNING IN THE README ABOVE! <--
--> DO NOT USE THIS TO 'FIX' IMAGES WHICH YOU PLAN TO SEND TO REDUMP! <--

Source: http://winaoe.org/redump/cdxafix-0.2.tar.gz
Win32 binary: http://winaoe.org/redump/cdxafix-0.2-bin-win32.zip

2 (edited by Jackal 2013-01-11 14:43:40)

Great job big_smile Hopefully we'll have some more use for it soon (maybe someone remembers some unmatched psx images with non-fixable cdmage errors that we can test it on)

Tested with a CDI image, which contains lots of Mode 2 Form 2 frames, and cdxafix.exe reports Sector is not a mode 2 form 2 sector.

I am sure that my image contains Mode 2 Form 2 frames because Sector View of IsoBuster shows in Status Bar Extracting Mode 2 Form 2, and refuse to show sector's contents if RAW checkbox is unchecked. And according to Browse Sector function of CDMage, many sectors contains just sync, header, subheader, user data and EDC fields, no ECC data.

Also I have noticed that CDMage won't open a CDI image through a .cue file with TRACK 01 MODE2/2352 directive. You have to change TRACK 01 MODE2/2352 ----> TRACK 01 CDI/2352 in order to enable CDMage to open such image.

On semi-vacation. MSF/AMSF to LBA/offset and viceversa calculator: link
To write properly occidental characters contained in japanese titles: screenshot
Spaces must be the fullwidth variant: link / screenshot

4

As I have no CD-i discs, can you extract a sector for me to test with?

Of course, I have extracted a range to test with:

http://www.mediafire.com/?2fgo6yeybuc8kag

On semi-vacation. MSF/AMSF to LBA/offset and viceversa calculator: link
To write properly occidental characters contained in japanese titles: screenshot
Spaces must be the fullwidth variant: link / screenshot

6

Thanks, got the bits rotated, sorry about that.
I updated to 0.2, can you recheck if it now works?

7 (edited by pablogm123 2013-01-11 16:30:46)

Untouched sector:
Sector ECD matches sector data. No fix required.

Modified sector:
247  08 -> 09  (1 bit fix)
502  07 -> 56  (3 bit fix)

First fix suggested is the correct one, because I changed that byte from 09 to 08. And I have performed another one-byte changes and cdxafix.exe can suggest every time the right value.

On semi-vacation. MSF/AMSF to LBA/offset and viceversa calculator: link
To write properly occidental characters contained in japanese titles: screenshot
Spaces must be the fullwidth variant: link / screenshot

8 (edited by V. 2013-01-11 16:34:34)

Good to hear! thanks for the testing smile

I just seen a bug in my code because of your post... it should say EDC, not ECD roll.
Will be fixed in a next release.