Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DVD-rom SCSI commands, reading raw sectors

270 views
Skip to first unread message

Rene Engbers

unread,
Sep 21, 1998, 3:00:00 AM9/21/98
to
Hello,

I am trying to read raw sectors (2064 bytes) from a DVD. I have tried
the Read-CD command (0xBE) but almost all my DVD-rom reject that
function (three out of four). However, my CD-rom players do accept
this command and return all the header end EDC/ECCdata.
I have also tried the Read(10) command (0x28) but via this command
one
can only read the normal data sectors (2048 bytes).

My question is: can someone tell me if there is another command, like
Read-CD, which can be used to obtain the raw sectors from a DVD

Thanks, Rene
--
Rene Engbers
r dot engbers at ehv dot tass dot philips dot com

Etienne Richards

unread,
Sep 26, 1998, 3:00:00 AM9/26/98
to
On 21 Sep 1998 10:04:39 GMT, "Rene Engbers" <Ple...@no.spam> wrote:

>I am trying to read raw sectors (2064 bytes) from a DVD. I have tried
>the Read-CD command (0xBE) but almost all my DVD-rom reject that
>function (three out of four). However, my CD-rom players do accept
>this command and return all the header end EDC/ECCdata.
>I have also tried the Read(10) command (0x28) but via this command
>one
>can only read the normal data sectors (2048 bytes).
>
>My question is: can someone tell me if there is another command, like
>Read-CD, which can be used to obtain the raw sectors from a DVD

Here's a sample that I wrote for one of the other news groups. This
sample was intended to look at the partition table but it also does
raw sector reading. You would see that I used PHYSICALDRIVE0 but you
can use you drive letter for CD-ROMS and DVD's.

I am not sure that this is what you want but I hope it helps.

//-------------------------------------------------------------------------------------------------
#include <windows.h>
#include <winioctl.h>
#include <stdio.h>

#include <iostream.h>

void ShowMedia(const MEDIA_TYPE &eMediaType);
void DumpBuffer(const LPBYTE pBuffer, DWORD dwSize);

int main( int argc, char** argv )
{
HANDLE hDisk;

//hDisk = CreateFile( "\\\\.\\C:",
hDisk = CreateFile( "\\\\.\\PHYSICALDRIVE0",
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL );

// get the drive geometry
if(hDisk != INVALID_HANDLE_VALUE)
{
cout << "Opened drive." << endl;

DISK_GEOMETRY dskGeometry;
DWORD dwActualSize;

if(DeviceIoControl( hDisk,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&dskGeometry,
sizeof(dskGeometry),
&dwActualSize,
NULL ) )
{
cout << "Drive geometry." << endl;

cout << "Cylinders : " <<
dskGeometry.Cylinders.LowPart << endl;
cout << "Cylinders : " <<
dskGeometry.Cylinders.HighPart << endl;
ShowMedia(dskGeometry.MediaType);
cout << "TracksPerCylinder : " <<
dskGeometry.TracksPerCylinder << endl;
cout << "SectorsPerTrack : " << dskGeometry.SectorsPerTrack
<< endl;
cout << "BytesPerSector : " << dskGeometry.BytesPerSector
<< endl;

// read the sector from the drive
cout << "Reading sectors from drive." << endl;

LPBYTE lpSector;
DWORD dwSize = 1 * dskGeometry.BytesPerSector;

// allocate memory on a segment boundary
lpSector = (unsigned char*)VirtualAlloc( NULL,
dwSize,
MEM_COMMIT |
MEM_RESERVE,
PAGE_READWRITE );

// move to sector 0
SetFilePointer( hDisk, 0, NULL, FILE_BEGIN );

// read the sector
ReadFile( hDisk, lpSector, dwSize, &dwActualSize, NULL );

// dump the buffer
DumpBuffer(lpSector, dwActualSize);

// get the disk drive layout
BYTE
aucBuffer[sizeof(PARTITION_INFORMATION )*10];
DRIVE_LAYOUT_INFORMATION* pDskLayout =
(DRIVE_LAYOUT_INFORMATION*)aucBuffer;

if(DeviceIoControl( hDisk,
IOCTL_DISK_GET_DRIVE_LAYOUT,
NULL,
0,
pDskLayout,
sizeof(PARTITION_INFORMATION )*10,
&dwActualSize,
NULL ) )
{
cout << "Read partition info." << endl;

cout << "PartitionCount : " << pDskLayout->PartitionCount;

cout << "Signature : " << pDskLayout->Signature;

for( DWORD i = 0; i < pDskLayout->PartitionCount; i++ )
{
cout <<
"-------------------------------------------------------------------"
<< endl;
cout << "StartingOffset : " <<
pDskLayout->PartitionEntry[i].StartingOffset.LowPart << endl;
cout << "StartingOffset : " <<
pDskLayout->PartitionEntry[i].StartingOffset.HighPart << endl;
cout << "PartitionLength : " <<
pDskLayout->PartitionEntry[i].PartitionLength.LowPart << endl;
cout << "PartitionLength : " <<
pDskLayout->PartitionEntry[i].PartitionLength.HighPart << endl;
cout << "HiddenSectors : " <<
pDskLayout->PartitionEntry[i].HiddenSectors << endl;
cout << "PartitionNumber : " <<
pDskLayout->PartitionEntry[i].PartitionNumber << endl;
cout << "PartitionType : " <<
pDskLayout->PartitionEntry[i].PartitionType << endl;
cout << "BootIndicator : " <<
pDskLayout->PartitionEntry[i].BootIndicator << endl;
cout << "RecognizedPartition : " <<
pDskLayout->PartitionEntry[i].RecognizedPartition << endl;
cout << "RewritePartition : " <<
pDskLayout->PartitionEntry[i].RewritePartition << endl;
cout <<
"-------------------------------------------------------------------"
<< endl;
}
}
else
{
cout << "Error getting physical disk info!" << endl;
}

// free the memory
VirtualFree(lpSector, 0, MEM_RELEASE);
}
else
{
cout << "Error getting drive geometry!" << endl;
}

}
else
{
cout << "Could not open drive!" << endl;
}

CloseHandle(hDisk);
return 0;
}

void DumpBuffer(const LPBYTE pBuffer, DWORD dwSize)
{
int count = 0;

for( DWORD i=0; i < dwSize; i++ )
{
printf( "%c", pBuffer[i], pBuffer[i] );
count++;

if( count == 64 )
{
printf( "\n" );
count = 0;
}
}
}

void ShowMedia(const MEDIA_TYPE &eMediaType)
{
if( eMediaType == Unknown )
{
cout << "Format is unknown" << endl;
}
else if( eMediaType == F5_1Pt2_512 )
{
cout << "5.25\", 1.2MB, 512 bytes/sector" << endl;
}
else if( eMediaType == F3_1Pt44_512 )
{
cout << "3.5\", 1.44MB, 512 bytes/sector" << endl;
}
else if( eMediaType == F3_2Pt88_512 )
{
cout << "3.5\", 2.88MB, 512 bytes/sector" << endl;
}
else if( eMediaType == F3_20Pt8_512 )
{
cout << "3.5\", 20.8MB, 512 bytes/sector" << endl;
}
else if( eMediaType == F3_720_512 )
{
cout << "3.5\", 720KB, 512 bytes/sector" << endl;
}
else if( eMediaType == F5_360_512 )
{
cout << "5.25\", 360KB, 512 bytes/sector" << endl;
}
else if( eMediaType == F5_320_512 )
{
cout << "5.25\", 320KB, 512 bytes/sector" << endl;
}
else if( eMediaType == F5_320_1024 )
{
cout << "5.25\", 320KB, 1024 bytes/sector" << endl;
}
else if( eMediaType == F5_180_512 )
{
cout << "5.25\", 180KB, 512 bytes/sector" << endl;
}
else if( eMediaType == F5_160_512 )
{
cout << "5.25\", 160KB, 512 bytes/sector" << endl;
}
else if( eMediaType == RemovableMedia )
{
cout << "Removable media other than floppy" << endl;
}
else if( eMediaType == FixedMedia )
{
cout << "Fixed hard disk media" << endl;
}
else
{
cout << "Opps !" << endl;
}

}


0 new messages