Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically copying a CD, byte for byte

Tags:

c++

c#

windows-7

I was wondering if anyone knew of a way in which I can just make a byte for byte copy of the data on a CD via programming? Are there some system calls available that can do this stuff?

I have a CD that is somehow corrupted or otherwise damaged, making some of the files inaccessible through explorer, etc. I know that there is information on there, and I would like to be able to make a copy of it (even in its damaged state) but of course I can't do that through the file system.

like image 962
A.R. Avatar asked Dec 17 '11 15:12

A.R.


1 Answers

A CD frame is 2352 bytes. For a data CD, this is 2048 bytes of data + miscellaneous headers and ECC, but you can read most of the raw frame data. The drive may trim off a few bytes. So bypassing the ISO 9660 filesystem and reading the CD in raw mode is your best bet. Reads will fail with an error on unrecoverable frames, but you may be able to seek past them and just start reading the next frame.

On linux you would open the low level SCSI device, issue an ioctl to set CDROMREADRAW and use read and lseek as required.

Description of CD programming guts is here.

This page has info on reading CDROM on Windows, but does not explain whether it is returning raw data or not.

like image 85
Steve C Avatar answered Sep 18 '22 15:09

Steve C