PC Floppy Copy Protection: XEMAG Xelok

This is part 5 of a series of articles investigating various floppy copy-protection schemes seen on the IBM PC platform. You may wish to read the previous entries in this series:

XEMAG was a commercial disk duplicator that provided services to companies such as Electronic Arts, Activision, IBM, Ashton-Tate, and Oracle.

XEMAG traces its origins to the disk duplication department of Peripheral Marketing, Inc., from which it was spun-off in 1983. By 1983 they were duplicating a million floppies a month. 


Reproduction of a design appearing on some XEMAG swag

 

For some background into what working at XEMAG was like, you may wish to read this interview with Peter Brown, a former XEMAG employee.

XEMAG was acquired by the Xidex Magnetics Corporation in February of 1983, for $3.78 million. Xidex would then acquire disk manufacturer Dysan in early 1985. Dysan had its own line of disk duplication equipment, which XEMAG would begin using along with Formaster and Trace devices. The end of 1988 would mark the production of their 1 billionth floppy disk.

XEMAG developed their own protection technology in-house which they offered to clients.  There is  even some indication that XEMAG developed the Interlock protection for Electronic Arts.

In 1984, XEMAG relocated their headquarters to the Silicon Valley city of Menlo Park.

This is going to be a bit of a short article, as there's no real significant drama surrounding XEMAG, other than a series of corporate acquisitions and restructuring over its history. The protection methods discussed here are not extreme.

XELOK

XEMAG used the trade name XELOK for several versions of their in-house copy protection, which appeared as different schemes depending on platform.

On the Apple II and Commodore 64, the Xelok protection scheme involved the use of "fat tracks," which you could think of a single track that was twice as wide as normal, or somehow two tracks of data duplicated perfectly with no gap in between.  A copy-protected title could check it was running from the original disk by seeking between the logical tracks contained within this wide track while reading, and ensuring no data errors resulted.  

This would have been near-impossible to duplicate on standard floppy drive. Creating this track required use of a special disk drive.

Luckily for us, you cannot step the drive head while reading on the PC, thanks to the limitations of the standard NEC floppy controller command set. XEMAG's Xelok protection had to take a different form on the IBM platform.

There were at least two versions of Xelok on the PC, which I will call Xelok v1 and Xelok v2.

I can't help but note that according to this dictionary, the word 'Xelok' in the Mayan language means to split or crack. I'm sure this is just some sort of cosmic coincidence.

Xelok v1

One game protected by Xelok v1 is the 1984 PC Booter release of SARGON III, the third edition of the famous computer chess engine. We can tell due to the contents of the disk's FM-encoded protection mark sector on Track 40, which contains:

NO VERSION #....XELOK IBM-PC (DUP) 5" 48/40 1S DD 8-SS.

Let's take a look at the disk surface:

Sargon III (PC Booter) (1984)

Right off the bat we start each track with an unusual ID of 27, which overlaps Sector 1, and has a bad data CRC as a result.  What's more interesting is at the end of each track - we have 16 sector IDAMs without any DAMs to match!

A bit of a refresher if you need it. Each sector on a floppy disk usually consists of two parts - a sector header, which contains an ID Address Mark, which is the specially-encoded sequence 0xA1, 0xA1, 0xA1, 0xFE.  Following the address mark are IDs for that sector's cylinder, head, sector, and finally a value representing the size of the sector and a CRC to validate the entire sector header. 

Once a disk drive has located the sector header it was looking for, it must get ready to actually read or write the sector data.  To accommodate the timings involved, there is a a gap (GAP2) of several bytes between the header and the actual sector data.  The data then follows, starting with a Data Address Mark (DAM). 

Nothing actually forces you to write any data after a sector header, though, and since a sector header by itself is quite small, we can cluster a bunch of them together back-to-back. Naturally, it would be hard to trick a PC's floppy controller to reproduce this.

This scheme might be a bit of a problem for MartyPC, as I currently only notate a sector when I find a DAM - and I populate the sector metadata with the values from the last IDAM seen.  We will need to modify our approach a bit. We can add a 'data_missing' flag to our sector metadata, and push a sector with that flag set if we encounter another IDAM instead of the DAM we expected.

Without such a fix, we get stuck here:

Failing the protection check

When we attempt to read a sector without a DAM, we need to return the right controller status codes. Specifically, we must return abnormal termination and the 'NDAM' bit in the ST2 status byte should be set when valid DAM cannot be found.

With that accomplished, how about a nice game of chess?

Sargon III in MartyPC

All those extra IDAMs take up a lot of space at the end of the track. This scheme was likely not feasible once 9-sectored disks became commonplace and needed the room that they occupied. That means we needed a new version of Xelok...

Xelok v2

One title protected by Xelok 2 is the classic strategy title from Brøderbund, The Ancient Art of War.

As confirmation, the duplication mark on track 40 contains the following:

NO VERSION #....-XELOK2-IBM PC PRT (DUP) - 5" 48/40 2S DD 9SS

Here's what the disk surface of side 0 looks like:

The Ancient Art of War (1985) 

The only thing notable here is Track 10, which contains 18 sectors in overlapped pairs. Despite being overlapped, both sectors in each pair have a valid CRC, which would have been difficult to duplicate.

Nothing here requires any new capabilities from our floppy disk code, so it works straight away:

The Ancient Art of War in MartyPC

XELOK2.SYS

On a Xelok 2 protected title, you may find a hidden file named XEMAG.SYS or XELOK2.SYS.  The latter file is present on the disk of The Ancient Art of War, and is 5119 bytes long.

If you copy XELOK2.SYS to your hard disk using standard DOS commands, you'll find that it does not seem to contain code. At first glance, it appears to contain nonsense. Well, not entirely nonsense if you've stared at enough sector dumps:


0000  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
0010  F6 F6 F6 F6 F6 F6 F6 F6 4E 4E 4E 4E 4E 4E 4E 4E  ööööööööNNNNNNNN
0020  4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E  NNNNNNNNNNNNNNNN
0030  4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E  NNNNNNNNNNNNNNNN
0040  4E 4E 4E 4E 4E 4E 4E 4E 00 00 00 00 00 00 00 00  NNNNNNNN........
0050  00 00 00 00 A1 A1 A1 FE 09 00 0D 02 7C 75 4E 4E  ....¡¡¡þ....|uNN
0060  4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E 4E  NNNNNNNNNNNNNNNN
0070  4E 4E 4E 4E 00 00 00 00 00 00 00 00 00 00 00 00  NNNN............
0080  A1 A1 A1 FB F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  ¡¡¡ûöööööööööööö
0090  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00A0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00B0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00C0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00D0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00E0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö
00F0  F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6 F6  öööööööööööööööö

If you look closely at line 0050, you can see the tell-tale sequence of a Sector ID Address Mark (IDAM) - 0xA1, 0xA1, 0xA1, 0xFE.  This file is mapped onto the protection track, so what we are seeing is an "inner" sector in this overlapped sector scheme.

5119 bytes is enough to get us most of the way around the protection track, so we can see the contents of 8 separate sectors when reading this file.  Unlike the Superlok protection track, all the sectors on the Xelok protection track are filled with the standard fill byte 0xF6, so do not contain an encryption key, although I can't rule out that the data in these sectors couldn't have been used for such a purpose.

Mapping this file over the protection track is a clever way of accessing the protection track data without making obvious calls to disk interrupt 13h or issuing a Read Track command directly to the controller.  This way, the guts of DOS file loading code will perform the work for us, making it less obvious target to hook. But that wouldn't have fooled anyone for very long.

An Easy Bypass?

The Xelok 2 protection relies on a protection track with 18 sectors - doubling up the standard 9 sectors in an overlapped fashion.  This would have been difficult to reproduce for a standard PC floppy controller - at least, at the time of its introduction. 

When the 1.44MB floppy drive was introduced to the PC world in 1987, the standard number of sectors per track was doubled - from 9 to 18. 

If the protection wants to see 18 sectors - surely it couldn't be as simple as copying the game to a 1.44MB diskette?  I replicated this setup in the 86Box emulator and sure enough, after configuring an AT system for a 360K drive A: and a 1.44MB drive B:, it was as simple as issuing the command:

diskcopy a: b:

After the copy operation was complete, executing b:war started the game as normal.

Fooling Xelok 2 with a 1.44MB floppy

Thanks again to NewRisingSun for the tip, which I first saw on the VOGONS forums.

XEMAG Cloaking Device

Curiously, a modest advertisement appears in PC magazines around 1987 describing a "Cloaking Device" protection scheme:


Was this a variant of XELOK with additional software support for hard disk installs, or something new entirely? If you know, leave a comment!





Comments

Popular posts from this blog

PC Floppy Copy Protection: Softguard Superlok

PC Floppy Copy Protection: Formaster Copy-Lock

The Complete Bus Logic of the Intel 8088