Click here to Skip to main content
13,050,237 members (98,304 online)
Click here to Skip to main content
Add your own
alternative version


39 bookmarked
Posted 19 Sep 2002

Write a UDF CDR

, 22 Jul 2003
Rate this:
Please Sign up or sign in to vote.
How to write a CDR in UDF


Some electronic devices need to use CDR as storage media, and you have to append several files each time before the space is used out. In this case, UDF is a good solution, since for each writing, only 7 logic blocks of overhead are used. (Multisession CDs use several minutes for each session's leadout)


How to use the demo

(You need WNASPI32.dll to run the demo, which could be downloaded from Ahead.)

  • Select the CDR drive you want to write to.
  • Insert a blank disc, "Format" it.
  • Browse to select files, and write to the disc. (Now you can view the files using DirectCD).
  • You can list the content of the CDR, and restore files to hard disk
  • Close Session, now any CD drive can read it..


How to use the source code

//Create a variable for your drive
SCSI2 m_drive;
//m_HA:HostAdpaterNumber,m_ID:SCSI ID,m_LUN:LogicUnitNumber
//For a blank CDR, you need to format it 
//Then you can write files onto it
//Append more files here...
//After you have writen ALL the files, close the session
//Now it's readable by regular CDROM drive.


Some useful functions

SCSIRead()      //Read data from CDR
WritePacket()      //Write packets to CDR
ReadTrackInfo()      //Read track info, like next writable address
ReadDiskInfo()      //Read disc info, like capacity
TestUnitReady()      //See if the drive is ready
LoadUnload()      //Eject/Close the tray
SetWriteParameters()    //Set write mode
SCSISetSpeed()      //Set read/write speed
ListFiles()      //List files on the CDR
SaveFileAs()      //Save file on CDR to hard disk

If you want to know more inside stuff

Things you need to have:

  • SCSI command block structure (ANSI X3.131-1994)
  • SCSI multimedia commands-2 (ANSI NCITS 333-2000)
  • OSTA specs: ECMA-167, Universal Disk Format Specification, ECMA-119

Things you need to know:

  • SCSI2 block command structure
  • Use of ASPI
  • Concepts about CDR: track, session, logical blocks, PMA, ATIP, TOC, write modes...
  • UDF(Volume structure, file system)

More info at my website.

Revision History

  • Ver 1.01
    • More comments, some code clean up
    • New function: ListFiles()
    • New function: SaveFileAs()
  • Ver 1.02
    • Some changes on the demo application


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United States United States
Wheels I reinvented on various embedded systems

*License Plate Reader
*TCP/IP stack
*Web Server
*Ethernet/SCSI/USB drivers
*FAT32/UDF file system
*JPEG/MJPEG encoder

You may also be interested in...

Comments and Discussions

GeneralRe: ATAPI Pin
Kochise16-Dec-02 23:56
sussKochise16-Dec-02 23:56 
GeneralRe: ATAPI Pin
Lailornd21-Dec-02 0:53
memberLailornd21-Dec-02 0:53 
GeneralRe: ATAPI Pin
Hongfeng31-Dec-02 11:29
memberHongfeng31-Dec-02 11:29 
GeneralRe: ATAPI Pin
Kochise2-Jan-03 0:17
sussKochise2-Jan-03 0:17 
GeneralRe: ATAPI Pin
Tuan Hung26-Apr-05 18:39
memberTuan Hung26-Apr-05 18:39 
GeneralUDF file size limit Pin
Mark Gargett10-Oct-02 22:10
sussMark Gargett10-Oct-02 22:10 
GeneralRe: UDF file size limit Pin
mgargett14-Oct-02 5:46
sussmgargett14-Oct-02 5:46 
GeneralRe: UDF file size limit Pin
Hongfeng14-Oct-02 11:16
memberHongfeng14-Oct-02 11:16 
GeneralATAPI drive Pin
Hongfeng3-Oct-02 7:34
memberHongfeng3-Oct-02 7:34 
GeneralRe: ATAPI drive Pin
Chisoft8-Oct-02 22:40
sussChisoft8-Oct-02 22:40 
Questionhow about ISO and CDA ? Pin
Mario M.3-Oct-02 0:29
memberMario M.3-Oct-02 0:29 
AnswerRe: how about ISO and CDA ? Pin
Hongfeng3-Oct-02 3:43
memberHongfeng3-Oct-02 3:43 
GeneralRe: how about ISO and CDA ? Pin
Mario M.3-Oct-02 12:22
memberMario M.3-Oct-02 12:22 
GeneralRe: how about ISO and CDA ? Pin
tootall9-Feb-03 4:16
membertootall9-Feb-03 4:16 
GeneralRe: how about ISO and CDA ? Pin
fengrxr3-Jun-03 16:31
memberfengrxr3-Jun-03 16:31 
Questioncan not format disc Pin
Anonymous24-Sep-02 19:38
sussAnonymous24-Sep-02 19:38 
AnswerRe: can not format disc Pin
Hongfeng25-Sep-02 3:41
memberHongfeng25-Sep-02 3:41 
GeneralProblem Pin
chen23-Sep-02 23:34
memberchen23-Sep-02 23:34 
GeneralRe: Problem Pin
Hongfeng24-Sep-02 5:52
memberHongfeng24-Sep-02 5:52 
GeneralRe: Problem Pin
chen2-Oct-02 20:08
memberchen2-Oct-02 20:08 
GeneralRe: Problem Pin
Anonymous9-Oct-02 3:58
sussAnonymous9-Oct-02 3:58 
GeneralRe: Problem Pin
chen9-Oct-02 5:13
memberchen9-Oct-02 5:13 
GeneralRe: Problem Pin
Hongfeng9-Oct-02 5:46
memberHongfeng9-Oct-02 5:46 
GeneralRe: Problem Pin
tututoto29-Jan-03 23:22
membertututoto29-Jan-03 23:22 
GeneralNice to know how it works, but... Pin
Kochise23-Sep-02 0:35
sussKochise23-Sep-02 0:35 
GeneralRe: Nice to know how it works, but... Pin
Hongfeng23-Sep-02 4:03
memberHongfeng23-Sep-02 4:03 
GeneralRe: Nice to know how it works, but... Pin
Christian Graus23-Sep-02 12:03
memberChristian Graus23-Sep-02 12:03 
GeneralRe: Nice to know how it works, but... Pin
Kochise23-Sep-02 21:41
sussKochise23-Sep-02 21:41 
GeneralRe: Nice to know how it works, but... Pin
Hongfeng24-Sep-02 5:37
memberHongfeng24-Sep-02 5:37 
GeneralRe: Nice to know how it works, but... Pin
Kochise24-Sep-02 5:53
sussKochise24-Sep-02 5:53 
GeneralRe: Nice to know how it works, but... Pin
Hongfeng24-Sep-02 6:08
memberHongfeng24-Sep-02 6:08 
GeneralLegality... Pin
Christian Graus22-Sep-02 17:46
memberChristian Graus22-Sep-02 17:46 
GeneralRe: Legality... Pin
Joao Vaz23-Sep-02 1:53
memberJoao Vaz23-Sep-02 1:53 
GeneralRe: Legality... Pin
Hongfeng23-Sep-02 3:56
memberHongfeng23-Sep-02 3:56 
GeneralRe: Legality... Pin
Joao Vaz23-Sep-02 4:19
memberJoao Vaz23-Sep-02 4:19 
QuestionA Little Dangerous....? Pin
Fred21-Sep-02 4:42
memberFred21-Sep-02 4:42 
AnswerRe: A Little Dangerous....? Pin
Hongfeng21-Sep-02 14:15
memberHongfeng21-Sep-02 14:15 
GeneralRe: A Little Dangerous....? Pin
Fred22-Sep-02 2:09
memberFred22-Sep-02 2:09 
GeneralGood~~ Pin
Leaves21-Sep-02 4:17
memberLeaves21-Sep-02 4:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170713.1 | Last Updated 23 Jul 2003
Article Copyright 2002 by spotofleopard
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid