Well, It's the most talked about protection in the CD world. But what is it? What makes it tick? That's what this page tries to answer.

First off, You must understand what XOR is (Exclusive OR). XOR is a bitwise operation (meaning it operates on individual bits in a stream, not bytes etc.) The Basic principle is that XOR'ing with a 1 flips a bit, and XOR'ing with a 0 does not. Note that XOR'ing a data pattern with the same stream twice will be equal to the original data.

Input/Output XOR Table

Input Bit 1 | Input Bit 2 | Output Bit |

1 | 1 | 0 |

1 | 0 | 1 |

0 | 1 | 1 |

0 | 0 | 0 |

For Example: The pattern 100001100101 XOR'd with the pattern 100101010010 would produce the pattern: 100100110111

You must also understand that CD-ROMs are analogue representations of digital data, and thus, are subject to the problems of damage, and that they must be read using electrical devices. Due to this, there are some safeguards to ensure that the CD's can be read reliably.

1: It is hard for the laser to reliably detect frequent
changes between pits and lands. Therefore, the number of pits and lands
cannot change frequently.

2: To satisfy this need, the number of changes needs
to be minimized.

3. A binary 1 is designated by the change from a pit
from a land, or vice versa, and a 0 as a lack of such a change.

4. Since a 1 is a change between a pit and a land, and
a change is hard to detect, we want to minimize the number of 1's in a
data stream that will be placed on the CD.

5. To ensure that this happens, an invention known as
EFM (Eight to Fourteen Modulation) was invented. This turns 8 bits into
14 bits, as given by a lookup table. These bits are chosen so that there
are at least 2, and at most 10, 0's between any 1's (The max of 10 zero's
is because if there is a very long pit or land, the drive can again lose
the ability to track correctly). Remember that since a 0 is designated
as a lack of a change, the drive doesn't have to keep up with so many changes.

You can find an EFM table here.

6. Because some EFM outputs end and/or begin in 1, it is not possible to put two EFM encoded outputs directly next to each other, and still obey the minimum of two and maximum of ten 0's between two one's. Therefore, merging bits were introduced. There are 3 merging bits between each two EFM encoded bytes. Two merging bits would be enough to satisfy the Min of 2, Max of 10 rule, a third is added to ensure that the Digital Sum Value (DSV) is close to zero.

The Digital Sum Value is integral to understanding the problem with weak sectors. The DSV is an integer, that changes at each point along the CD. For every pit on the CD, the DSV is incremented by one, and for every land it is decremented by one. For instance, take the following series of pits and lands:

Pit-Pit-Pit-Pit-Land-Land-Land-Pit-Pit-Land-Land-Land-Land.

The DSV for that small sequence would be -7 (The number of lands), +6 (The number of pits), or -1.

The CD-Reader has trouble reading CD's with a high DSV, because (Not sure about this info, this is just an idea from Pio2001, a trusted source), the pits return little light when they are read. The CD drive cannot reliably track in this situation, so it reports a read error.

The merging bits are chosen so that:

1. The Min of 2, Max of 10 rule is obeyed.

2. The pattern 100000000001000000000010 occurs only at the position for
the Sync Header (The synch header is at the beginning of every sector.
It is useful in helping to find a given position in a sector. If it appeared
somewhere else, it would confuse the drive)

3. The DSV is kept as close to 0 as possible.

As found in Annex E of the ECMA-130:

Feeding a regular bit pattern into the EFM encoder can cause a situation in which the merging bits are not sufficient to keep the DSV low. For example, if the EFM encoder were fed with the bit pattern "D9 04 D9 04 D9 04 D9 04 D9 04 D9 04 D9 04 D9 04 D9 04 D9 04 D9 04" (Note: These values are in Hexadecimal), than there would be a high DSV. Since there are many times in which one would need to write a regular bit pattern, a "Sector Scrambler" was introduced. The sector scrambler, obviously, scrambles the sectors. It does this by XOR'ing them with the output of a shift register. A shift register basically outputs random-appearing data, thus, when XOR'ed with the non-random sector, greatly reduces the risk of a regular bit pattern ever being fed to the EFM encoder.

You're probably wondering what all this has to do with
SafeDisc 2.

Well, SafeDisc 2's weak sectors are already XOR'd with
what the output of the sector scrambler will be. So, since the sectors
will be scrambled before they reach the EFM encoder, and since any data
pattern XOR'd with the same pattern twice will result in the original data
pattern, the EFM encoder will have to write the twice scrambled (or in
other terms, the unchanged) sectors, which are regular bit patterns.

Here is where we run into the problem. The algorithm for calculating the merging bits is far too slow to be viable in an actual CD-Burner. Therefore, CD designers had to come up with their own algorithms, which are faster. The problem is, when confronted with the weak sectors, the algorithms cannot produce the correct the merging bits. This results in sectors filled with incorrect EFM-Codes. This means that every byte in the sector will be interpreted as a read error. The error correction is not nearly enough to correct every byte in the sector (obviously).

The SafeDisc 2 guard module checks the weak sectors, searching for read errors. If one is found, it assumes that the disc is a copy, and refuses to run.

Well, that's about it. Check out the CD
Freaks Board for more info, and more news from the scene.