Alex

EDCRE: EDC/ECC Regenerator For BIN+CUE CD Disc Images

An advanced solution to detect and or update EDC/ECC data to match any edits done to the data track of a BIN/CUE CD image.

Homepage Github

Table of Contents

Downloads

Version 1.0.8 (7/31/2024)

Changes:



Previous versions.

What Is EDC/ECC Data?

EDC is a special checksum that verifies the integrity of the user data portion of a sector in a data track. If during a sector read the EDC does not match the data read by the CD drive, ECC data then provides a way to correct the data to what was expected in most cases. If a significant amount of the sector is unreadable or modified this may not be correctable with ECC data, but in many common cases (i.e. slightly scratched discs) it does work quite well and provides much more reliability and resilience for data CD reading.

When you edit a data track in a CD image, the original EDC and ECC will remain untouched causing it to mismatch the new contents of the user data in any modified sectors, causing any changes to not take effect or invalidate the disc image when it is burned to a disc and used on real hardware. Usually this isn’t a problem however since almost all CD burning software writes updated EDC/ECC to burned discs, and most emulators ignore the EDC/ECC data in sectors by design. IMGBurn always writes updated EDC/ECC data, and there isn’t a way to disable that behavior. CDRDAO always writes updated EDC/ECC data when using the default generic-mmc driver. It is possible however specify the generic-mmc-raw be used instead which does not modify EDC/ECC data and leaves it as is. CloneCD always writes updated EDC/ECC data unless you use the RAW writing mode. Writing updated EDC data to disc is usually what you want, that way the correct matching EDC/ECC data correlates to any modification to the user data of sectors found in a disc image.

But what if you want to edit user data of sectors in a data track of a CD disc image and then write it raw? That is exactly what I want to do, as it defeats the EDC-based anti-piracy protection measure found in almost all of the Dance Dance Revolution PSX games.

PSX EDC Anti-Piracy Protection

The idea of EDC/ECC based additional anti-piracy protection is a brilliantly flawed one. See, Sony’s tools to generate disc images back in the day were buggy. One such bug appears to be that the reserved sectors 12-15, which are zero filled in the user data portion of the sector, also have an EDC checksum of zero. The correct checksum for a zero-filled user data sector should be 3F 13 B0 BE, but it isn’t. It’s 00 00 00 00 like the rest of the sector besides the sync data. This actually doesn’t matter in practice, so the bug went unoticed and the technically invalid sector 12-15s shipped on real licensed PSX CD-ROMs. This apparently got fixed eventually in some newer version of the cdgen Sony tool that created disc images.

Someone working on the Dance Dance Revolution PSX games noticed this strange behavior and figured out that it could be exploited as an additional anti-piracy protection measure. If the real licensed PSX CD-ROM discs were shipped with an EDC checksum of zero in sector 12-15, then when someone went to rip the real licensed PSX CD-ROM disc and then burn it back to a CD-R, the EDC checksum in sector 12-15 would no longer be 00 00 00 00, it would be the expected 3F 13 B0 BE. Game code can read the EDC checksum on the disc at sector 12, and a routine could then lock up the game if the EDC data is non-zero to deter piracy.

PSX EDC Protection Workaround With EDCRE

EDCRE has a simple solution to allow edited/patched PSX disc images that have EDC Protection to work on real PSX hardware. By using the -s 16 argument, you can not touch the checked sector (12) and instead only regenerate EDC/ECC data for all data sectors starting at the system volume descriptor sector (16/LBA 166).

if you burn the disc image RAW using CloneCD or CDRDAO. At the same time any edits/patches made to a PSX disc image will have matching EDC/ECC data (since any such edits would be on the game data itself which starts at the 16th sector) allowing patches to the data track work correctly on real hardware.

Usage

EDCRE is a command line program. On Windows and most Linux distributions, you can simply drag and drop the “track 01.bin” file of the PSX game you want to update EDC/ECC data for.

If you want to see more verbose info, and or if you want to update EDC/ECC data for all sectors (what you probably want if the data track bin file is not an EDC Protected PSX game but rather something else), you need to execute edcre with command line options:

Usage: edcre

The data track bin file. This is the first (i.e. track 01) or only bin file in a bin/cue cd image

Optional Arguments:

-v Verbose, display each sector LBA number containing invalid EDC data, if any.

-t Test the disc image for sectors that contain invalid EDC/ECC. Does not modify the data track bin file in any way.

-s Start EDC/ECC regeneration at sector number following the -s argument instead of at sector 0. In example, -s 16 starts regeneration at sector 16 (LBA 166) which would be the system volume for a PSX disc image (and what is recommended most of the time). TOCPerfect Patcher users want -s 15 here however.

-k Keep existing sector header data from data file. This prevents EDCRE from regenerating the MM:SS:FF in the sector header. Useful for testing or regenerating EDC/ECC in a disc image file snippet (i.e. the last data track pregap of a Dreamcast GD-ROM image doesn’t start at sector 0 and is a separate file).`


Windows

Linux

EDCRE

Burning EDCRE Patched Disc Images

CDRDAO v1.2.5

The latest CDRDAO v1.2.5 also supports burning EDC Protected PSX games with CD audio tracks correctly using the generic-mmc-raw driver. There are pre-built portable releases of a new enough CDRDAO for Linux available. The required command syntax for burning EDCRE patched games is this:

cdrdao write --speed x --driver generic-mmc-raw --swap -n --eject yourgame.cue

Breakdown what each of these arguments to CDRDAO do:

License

EDCRE is modified CDRDAO source code, which is licensed under the GPLv2 license. Please see the file license.txt in each release for full info.

Credits