-1

I managed extracted a single sector from a cd-rom bin file using a hex editor. According to cd-rom specifications the sector should have the following format: * 16 bytes for synchronization and header * 8 bytes for the sub-header * 2048 bytes for user data * 4 bytes for the EDC which happens to be a CRC32 applied to user data and sub-header.

I found detailed information on this matter on page 55 of the following document: https://ia800408.us.archive.org/4/items/cdi_may94_r2/cdi_may94_r2.pdf

I want to manually modify user data in the sector, but in order to do that I must recalculate the EDC as well. (I assume ECC is ignored if EDC results are positive)

However, before modifying anything I want to check that I agree with my sector on the given CRC32. But, I can't. And that's the problem.

Here is my 2352 byte sector: https://drive.google.com/open?id=1CYAInG8TYMyRMOgR1zeooUrLK5CR7cmM

The EDC section has the following CRC32 result: 92 54 48 44 (hex)

But when I recalculate the CRC32 myself using HxD hex-editor I get: 55 32 CA 62

Why am I getting a different result? I tried changing input/output reflection in the custom CRC32 section, but nothing works. I've been stuck on this for an hour and couldn't find anything on google.

  • What exactly is the "cd-rom bin file" you extracted this data from? A CD-ROM image file normally wouldn't include the sync/header/ECC bytes, they exist only on the physical disc. Also, the file you linked to had a .dms extension, which appears to be an Amiga disk image format - which is compressed. Unless you somehow uncompressed the data, it's not surprising that you can't make any sense of it. – jasonharper Feb 16 '18 at 04:13
  • My source is a psx game (that I own) that came in a bin/cue format. This format is raw and thus it will contain the sync/header bytes that are present in every sector (the one that doesn't is the .iso). You can clearly see the sync code in the file I included (10 repeating 0xFF bytes at the very beginning). The file I linked to doesn't have an extension, it's nothing but a hex dump of the sector I was analyzing, and is meant to be viewed in a hex editor. I don't know why you saw .dms at the end... Open it up in the hex editor, you'll see what I'm talking about. – Gekuron Matrix Feb 16 '18 at 05:33

1 Answers1

0

I'm going to answer my own question since I finally found the answer:
The CRC32 used a different polynomial.

The typical forward/reverse values are: 0x04C11DB7 / 0xEDB88320
The forward/reverse values my cd-rom used: 0x8001801B / 0xD8018001

So if you wanted to recalculate the CRC32 manually in HxD hex-editor you would need to use a manual CRC with the following settings:

*Polynomial: 0x8001801B
*Initial value: 0
*Output XOR: 0
*Input & Output reflections checked.

Though CDmage can do all this automatically.

In the end all of this didn't help me because the emulator didn't give a flying goldfish over the EDC/ECC bytes. I should have known that.

After slightly changing a few text related bytes in my sector I noticed that the disk image couldn't load anymore, and thus, immediately assumed that EDC/ECC bytes were responsible. The real cause probably lies in the software somewhere.