CDR Signature format

User's guide:

Signatures Documentation

CorelDRAW CDR Signature Format: Specification & CDR Recovery Example

In its first versions, the CDR file format was a completely proprietary Corel file format primarily used for vector graphic drawings and developed by Corel Corp., recognizable by the first two bytes of the file being "WL".
Starting with CorelDRAW 3, the file format changed to a Resource Interchange File Format (RIFF) envelope, recognizable by the first four bytes of the file being "RIFF", and a "CDR*vrsn" in bytes 9 to 15, with the asterisk "*" being in early versions just a blank, and beginning with Corel Draw 4, the version number of the writing program in hexadecimal ("4" meaning version 4, "D" meaning version 14).

The actual data chunk of the RIFF remains a Corel proprietary format. From version X4 (14) on, the CDR file is a ZIP-compressed directory of several files, among them XML-files and the RIFF-structured files.

Any RIFF container, including CDR drawing must have a signature (tag) RIFF (hex: 52 49 46 46) at the beginning of the file.

Asterisk "*" being in early versions just a blank, and beginning with Corel Draw 4,
the version number of the writing program in hexadecimal ("4" meaning version 4, "D" meaning version 14).
Chunk size is data size plus 8 bytes. Summarizing size for all found chunks, we calculate total file size.

When inspecting sample.cdr file's data using any Hex Viewer, like Active@ Disk Editor, which is included in Active@ File Recovery package, we can see it starts with a signature RIFF (hex: 52, 49, 46, 46).
At offset 8 there is a signature of CorelDRAW Drawing RIFF Type CDR9 (hex: 43, 44, 52, 39), which means CDR file's version is 9.

Active@ File Recovery Custom Scripting Example

This example just determins cdr start signature and calculates file size based on the size specified in RIFF header. Some additional validation included.
Syntax of the signature definition language you can read here.