StarBurn SDK (Software Development Kit)
ContentsIndexHome
PreviousUpNext
StarBurn_CdvdBurnerGrabber_ReadCooked Function
C++
__stdcall STARBURN_IMPEX_API EXCEPTION_NUMBER StarBurn_CdvdBurnerGrabber_ReadCooked(IN PVOID p__PVOID__CdvdBurnerGrabber, OUT PCHAR p__PCHAR__ExceptionText, IN ULONG p__ULONG__ExceptionTextSizeInUCHARs, OUT PULONG p__PULONG__SystemError, OUT PCDB_FAILURE_INFORMATION p__PCDB_FAILURE_INFORMATION, OUT PUCHAR p__PUCHAR__Read, IN ULONG p__ULONG__ReadSizeInUCHARs, IN LONG p__LONG__LBA, IN ULONG p__ULONG__TransferSizeInLBs);
Parameters 
Description 
IN PVOID p__PVOID__CdvdBurnerGrabber 
Pointer to the CdvdBurnerGrabber object that toolkit allocated before.
 
OUT PCHAR p__PCHAR__ExceptionText 
Pointer to array of CHARs that will be used to store formatted exception description message.
 
IN ULONG p__ULONG__ExceptionTextSizeInUCHARs 
Size of the array of CHARs used to be formatted exception message storage.
 
OUT PULONG p__PULONG__SystemError 
Pointer to ULONG that will contain the system error (if some will occur).
 
OUT PCDB_FAILURE_INFORMATION p__PCDB_FAILURE_INFORMATION 
Pointer to CDB_FAILURE_INFORMATION that will be filled with apropriate values.
 
OUT PUCHAR p__PUCHAR__Read 
Pointer to data buffer to receive read data to.
 
IN ULONG p__ULONG__ReadSizeInUCHARs 
Read size in unsigned char(s).
 
IN LONG p__LONG__LBA 
Starting LBA to read from.
 
IN ULONG p__ULONG__TransferSizeInLBs 
Whole transfer size in logical block(s). 

Execution status. EN_SUCCESS if the operation completed successfuly. If the exception number will be EN_SYSTEM_CALL_FAILED, variable that SystemError points to will be filled with system error. If something other then EN_SUCCESS will be returned buffer that ExceptionText will point to will be filled with formatted exception message. If the exception number will be EN_SCSI_CDB_FAILED, CDB_FAILURE_INFORMATION will be filled with apropriate values (CDB that faled, CDB size, SCSI sense data, SCSI sense data size, SCSI transport, device and host adapter status codes).

This function reads one or more logical block(s) from the currently inserted CD/DVD/Blu-Ray/HD-DVD in cooked format.

Make sure your data buffer is page-aligned, transfer size is less then 64KB and all of the input parameters are valid.

This example allocates CdvdBurnerGrabber object, reads 2 (two) cooked logical blocks and destroys the device object after it's not needed any more. 

 

// Somewhere in the data region
PVOID l__PVOID__CdvdBurnerGrabber;
EXCEPTION_NUMBER l__EXCEPTION_NUMBER;
ULONG l__ULONG__SystemError;
CHAR l__CHAR__ExceptionText[ 1024 ];
CDB_FAILURE_INFORMATION l__CDB_FAILURE_INFORMATION;
TOC_INFORMATION l__TOC_INFORMATION;
UCHAR l__UCHAR__Buffer[ 8192 ]; // We do allocate buffer on the stack but it's not correct. Page-aligned memory must be used.

// Prepare exception text buffer
RtlZeroMemory(
    &l__CHAR__ExceptionText,
    sizeof( l__CHAR__ExceptionText )
    );

// Prepare CDB failure information
RtlZeroMemory(
    &l__CDB_FAILURE_INFORMATION,
    sizeof( l__CDB_FAILURE_INFORMATION )
    );

// Prepare the buffer
RtlZeroMemory(
    &l__UCHAR__Buffer,
    sizeof( l__UCHAR__Buffer )
    );

// Try to create CdvdBurnerGrabber on 0:0:4:0 with 32MB of cache
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_Create(
    &l__PVOID__CdvdBurnerGrabber,
    ( PCHAR )( &l__CHAR__ExceptionText ),
    sizeof( l__CHAR__ExceptionText ),
    &l__ULONG__SystemError,
    &l__CDB_FAILURE_INFORMATION,
    ( PCALLBACK )( StarBurn_Callback ),
    0,
    0,
    4,
    0,
    32
    );

// Check for correct reply
if (  l__EXCEPTION_NUMBER != EN_SUCCESS )
{
// Handle error here...
}

// Prepare TOC information buffer
RtlZeroMemory(
    &l__TOC_INFORMATION,
    sizeof( l__TOC_INFORMATION )
    );

// Get TOC information here and analyze it

// Get currently inserted disc and analyze it

// Try to grab two cooked logical blocks starting from LBA 100 (from TOC we know that address 100 is valid)
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_ReadCooked(
    l__PVOID__CdvdBurnerGrabber,
    ( PCHAR )( &l__CHAR__ExceptionText ),
    sizeof( l__CHAR__ExceptionText ),
    &l__ULONG__SystemError,
    &l__CDB_FAILURE_INFORMATION,
    ( PUCHAR )( &l__UCHAR__Buffer ),    // Pointer to data buffer to receive the payload
    sizeof( l__UCHAR__Buffer ),         // Data buffer size in unsigned char(s)
    100,                                // Start from logical block number 100
    2                                   // 2 logical blocks
    );

// Check for correct reply
if (  l__EXCEPTION_NUMBER != EN_SUCCESS )
{
// Handle error here...
}

// Do something with CdvdBurnerGrabber device object and read sectors here

// Destroy the CdvdBurnerGrabber
StarBurn_Destroy( &l__PVOID__CdvdBurnerGrabber );

// Just check for pointer (paranoid?)
if ( l__PVOID__CdvdBurnerGrabber != NULL )
{
// Handle error here...
}