CDWorks: Read, Write CDR/W [Project frozen]

Applications, Games, Tools, User libs and useful stuff coded in PureBasic
marroh
User
User
Posts: 72
Joined: Wed Aug 06, 2008 8:21 am

CDWorks: Read, Write CDR/W [Project frozen]

Post by marroh »

A friend asked me if I could program him a small component which is capable write ISO images to CD-R/W discs.
I saw it as a challenge, and so I said yes. Honestly, I had better said no way... was that a working.
First was the study of relevant documents from T10.org. This was followed by the study of the source code of cdrdao.
Finally I was able to make the finished component and my friend is (so far) happy.

At the moment, the DLL has not so many features, more will follow. On W2K, XP and Vista admin rights are required.
On Win7/Win8 user rights satisfies. Used Interface is SPTI, so no runtimes required.

Demo_cdwGetDriveInfo.pb > demo source shows information on attached CD ROM drives
Demo_cdwGetMediaInfo.pb > demo source shows information from drive present disc
Demo_cdwDrive2ISO.pb > demo source shows how create a iso image from drive with progress status
Demo_cdwISO2Drive.pb > demo source shows hor write a iso image to cd-r/w dvd-r/w disc.

Here the source of Demo_cdwGetDriveInfo.pb

Code: Select all

; CDWorks Lib v0.2 Demo for PureBasic.
; (c)2013 by MRware, all rights reserved.
; Free to use for freeware, use it at your own risk!

EnableExplicit

IncludeFile "cdwlib.pbi"

Procedure Main()
  Protected.l lNumDrives, lActDrive
  lNumDrives = cdwGetDriveCount()
  If lNumDrives > 0
    Debug "Found " + Str(lNumDrives) + " usable drives."
    For lActDrive = 1 To lNumDrives
      If cdwUseDrive(lActDrive) = #CDW_SUCCESS And cdwGetDriveInfo() = #CDW_SUCCESS
        Debug "Infos for drive #" + Str(lActDrive)
        Debug "Driveletter: " + PeekS(cdwGetDriveLetter())
        Debug "Drive Vendor: " + PeekS(cdwGetDriveVendor())
        Debug "Drive Product: " + PeekS(cdwGetDriveProduct())
        Debug "Drive Firmware: " + PeekS(cdwGetDriveFirmware())
      Else
        Debug "Can't get drive infos."
      EndIf
    Next
  Else
    Debug "No useable drives found."
  EndIf
EndProcedure

Main() : End
And the cdwlib.pbi include

Code: Select all

Enumeration
  #CDW_SUCCESS
  #CDW_ERROR_INVALID_DRIVE
  #CDW_ERROR_NO_DRIVE
  #CDW_ERROR_INVALID_ISO
  #CDW_ERROR_DRIVE_ACCESS
  #CDW_ERROR_GETPAGE
  #CDW_ERROR_PUTPAGE
  #CDW_ERROR_SET_WRITE_SPEED
  #CDW_ERROR_READ_TOC
  #CDW_ERROR_CREATE_FILE
  #CDW_ERROR_READ_ERROR
  #CDW_ERROR_WRITE_FILE
  #CDW_ERROR_WRITE_DISC
  #CDW_ERROR_USER_ABORT
  #CDW_ERROR_INQUIRY_ERROR
  #CDW_ERROR_NO_DISC
  #CDW_ERROR_INVALID_DISC
  #CDW_ERROR_ERASE_ERROR
EndEnumeration

Enumeration
  #CDW_DS_EMPTY
  #CDW_DS_INCOMPLETE
  #CDW_DS_COMPLETE
  #CDW_DS_UNKNOW
EndEnumeration

Enumeration
  #CDW_MT_INVALID
  #CDW_MT_CDRW
  #CDW_MT_CDR
  #CDW_MT_DVDRW
  #CDW_MT_DVDR
EndEnumeration

Import "cdwlib.lib"
  cdwGetDriveCount() As "_cdwGetDriveCount@0"
  cdwUseDrive(lDrive.l) As "_cdwUseDrive@4"
  cdwGetDriveInfo() As "_cdwGetDriveInfo@0"
  cdwGetDriveLetter() As "_cdwGetDriveLetter@0"
  cdwGetDriveVendor() As "_cdwGetDriveVendor@0"
  cdwGetDriveProduct() As "_cdwGetDriveProduct@0"
  cdwGetDriveFirmware() As "_cdwGetDriveFirmware@0"
  cdwISO2Drive(sISOImage.s, lCallback.l) As "_cdwISO2Drive@8"
  cdwDrive2ISO(sISOImage.s, lCallback.l) As "_cdwDrive2ISO@8"
  cdwLoadMedia() As "_cdwLoadMedia@0"
  cdwEjectMedia() As "_cdwEjectMedia@0"
  cdwLockMedia() As "_cdwLockMedia@0"
  cdwUnlockMedia() As "_cdwUnlockMedia@0"
  cdwIsMediaPresent() As "_cdwIsMediaPresent@0"
  cdwGetMediaInfo() As "_cdwGetMediaInfo@0"
  cdwGetMediaState() As "_cdwGetMediaState@0"
  cdwGetMediaType() As "_cdwGetMediaType@0"
  cdwGetDiscCapacity.q() As "_cdwGetDiscCapacity@0"
  cdwIsMediaEraseable() As "_cdwIsMediaEraseable@0"
  cdwEraseMedia(lFullErase.l) As "_cdwEraseMedia@4"
EndImport
Some important notes
The component is currently more suited for CD-R/W disc. Only restricted DVD support.
The erase a CD-RW disc blocked the further program sequence until the end of erase.
On the moment only cd-rw discs are supported by the cdwEraseMedia() command.
cdwGetDiscCapacity returns used data size on cd-r/dvd-r discs, disc capacity on cd-rw/dvd-rw discs.
As the writemode is TAO, it's normal only used for cd-r/cd-rw discs. I testet it with some iso dvd images too,
has worked fine for me but normal dvd write mode are DAO. I will implement even.

OK, enough said, hope can be useful... more features will follow / add in future.
Last edited by marroh on Thu Mar 21, 2013 2:22 pm, edited 1 time in total.
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !
marroh
User
User
Posts: 72
Joined: Wed Aug 06, 2008 8:21 am

Re: CDWorks: Read, Write CDR/W and more...

Post by marroh »

During the implementation of other features that I realized my error handling routines are insufficient.
Therefore I have decided to put the project temporarily on hold state, I lack the time to carry out the extensive changes.
At the time i make more music... therefore the project is expected to resume in late summer.

Code: Select all

code deleted
Last edited by marroh on Thu Mar 21, 2013 2:24 pm, edited 2 times in total.
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 796
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: CDWorks: Read, Write CDR/W and more...

Post by Zebuddi123 »

Hi marroh what did you use to create the data section ? thanks for sharing

Zebuddi. :D
malleo, caput, bang. Ego, comprehendunt in tempore
marroh
User
User
Posts: 72
Joined: Wed Aug 06, 2008 8:21 am

Re: CDWorks: Read, Write CDR/W and more...

Post by marroh »

Hi Zebuddi. I used my own bin2data source, but maybe ts-soft Bin2Data is usefull for you.
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !
Thorium
Addict
Addict
Posts: 1305
Joined: Sat Aug 15, 2009 6:59 pm

Re: CDWorks: Read, Write CDR/W and more...

Post by Thorium »

Great stuff. Thank you.

Will you add BIN/CUE support and does it work with multi track images (data and audio)?
marroh
User
User
Posts: 72
Joined: Wed Aug 06, 2008 8:21 am

Re: CDWorks: Read, Write CDR/W and more...

Post by marroh »

Hi Thorium, yes i will add bin/cue support soon. Also i will add support for all today data form modes for cd/dvd. Form Mode 1 / 2, RAW96, RAW96+SC, multitrack discs, compressed iso support and more. Maybe also paket writing modes. The next update first will bring support for read/write audio cd tracks, calculate the cddb-id, get more info about cdreader/cdwriter, events for operation states like write lead-in, write track, write lead-out, close disc. Also the sense data decoding - used for error handling and info - are improved. At all at the moment only iso images with 2048 bytes sectors are supported but more modes coming soon.
PureBASIC v5.41 LTS , Windows v8.1 x64
Forget UNICODE - Keep it BASIC !
Post Reply