StarBurn SDK (Software Development Kit)
ContentsIndexHome
Example

This example allocates CdvdBurnerGrabber object, reads 2 (two) RAW 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. We can do RAW read from CD media only

// Probe supported read modes as we need to read in the ones drive really supports

// Try to grab two RAW logical blocks starting from LBA 100 (from TOC we know that address 100 is valid)
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_ReadRaw(
    l__PVOID__CdvdBurnerGrabber,
    ( PCHAR )( &l__CHAR__ExceptionText ),
    sizeof( l__CHAR__ExceptionText ),
    &l__ULONG__SystemError,
    &l__CDB_FAILURE_INFORMATION,
    EXPECTED_LB_TYPE_ANY,               // Accept any logical blocks
    100,                                // Start from logical block number 100
    2,                                  // 2 logical blocks only
    ERROR_FIELD_NO_ERROR,               // No error data included
    TRUE,                               // YES, we need EDC/ECC data
    TRUE,                               // YES, we need user data
    HEADER_CODE_ALL_HEADERS,            // We need ALL of the headers
    TRUE,                               // YES, we need SYNC pattern
    SUBCHANNEL_RAW_PW,                  // Read RAW P-W subchannel from the disc
    ( PUCHAR )( &l__UCHAR__Buffer ),    // Pointer to data buffer to receive the payload
    sizeof( l__UCHAR__Buffer )          // Data buffer size in unsigned char(s)
    );

// 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...
}